In this paper, phosphorus-doped porous carbon was obtained via a simple method with leaves as raw materials, and its broad application prospects in sodium-ion and lithium-ion battery were proved. The effect of different mass ratios on microstructure and properties were investigated. Phosphorus-doped porous carbon has high specific surface area and pore volume, which is favorable for contact with electrolyte and transportation of electron/ion. Meanwhile, doping of phosphorus increases layer spacing of carbon lattice and enhances adsorption of sodium ion, which are more conducive to the storage of sodium ions. Based on above advantages, PC-3 has stable and fast sodium-ion and lithium-ion storage performance with capacity of 310.4 mAh g−1 for sodium-ion battery and 723.4 mAh g−1 for lithium-ion battery after 200 cycles. Furthermore, carbonization temperature of this method is lower than other reports, saving energy and having better practical value.