A scheme for the generation of phase-coded microwave signals using an electrically tunable photonic microwave phase shifter is proposed and demonstrated. The photonic phase shifter is based on a single-sideband polarization modulator (PolM), and the tuning of the phase shifter is implemented by a second PolM. By introducing an RF signal to the first PolM and an electrical coding signal to the second PolM, a phase-coded microwave signal with binary phase codes or polyphase codes is achieved. An experiment is performed. The simple and flexible operation, high coding rate, large frequency range, excellent transmission performance, and high stability of the system is confirmed.