C3N4 shows great potential for photo (electro)catalytic hydrogen production from water splitting. Elemental doping can modulate the band structure of C3N4, thereby broadening the responsive wavelength range, and facilitating charges' separation on C3N4. In this work, phosphorus was doped into C3N4 (PCN) using diammonium hydrogen phosphate as a precursor. Platinum nanoparticles were further photodeposited onto the surface of PCN. With these modifications, the photocatalytic activity in hydrogen production on C3N4 was increased from none to 5.9 μmol/h/gcat after phosphorus doping, and then to 312.5 μmol/h/gcat after Pt loading. Furthermore, C3N4 was grown on carbon cloth, its photoelectrocatalytic activity in hydrogen production was increased from 23.98 to 356.73 mmol/h/m2 after doping with P, and further increased to 400.39 mmol/h/m2 after loading with Pt. The increase in hydrogen production rate could be attributed to the fact that doping with P elements increased the specific surface area of C3N4, exposing more active sites in C3N4. And the loading of Pt nanoparticles accelerated charges’ transfer and separation, thus promoting the catalytic activity. The present study shows that the modification of C3N4 by doping with non-metals and loading metals plays an important role in improving the photo (electro)catalytic performance of C3N4.