The photocatalytic yield of the g-C3N4 for CO2 reduction was modified by phosphorus doping. The possible reaction pathways for CO2 reduction on the P-doped g-C3N4 (PCN) surface were investigated by DFT calculations for the first time. The experimental results showed that P doping improves the production of CH4 through the increase in the driving force of the electrons. The partial density of states of the PCN showed that the VBM and CBM are composed of px, py and s orbitals of the N atoms and pz states of carbon, nitrogen, and phosphorus, respectively and therefore, the P-doping increase carriers lifetime. Mechanism studies confirm that formic acid, formaldehyde, methanol and methane are the most probable products. The methane having positive adsorption energy can be easily desorbed from the PCN surface and the Gibbs activation energy of the final step is 1.98 eV. The formation of H2COOH is the rate-determining step.