PHP.net manual text and the user-submitted comments/code snippets are licensed under Creative Commons Attribution 3.0 (CC-BY 3.0).
You may reuse the code (even commercially), but you must provide proper attribution to the PHP Documentation Group or link back to the original source.