Unless you have root it's rather difficult to make a directory that the webserver can write to.
It's not specific to PHP, except that PHP is used for web scripting.
The correct way to do it, if you don't have root is:
Make a directory 777 (yes, you do need to). Have the webserver create a subdirectory owned by the webserver. Change the parent directory away from 777 to 755 or 775.
Double check that no one else created something in there while it was wide open.
Be aware that ALL users on that machine who can run web scripts have access to that directory.
An even better way is with mpm-itk
This increased when devops came on the scene, and it was probably one of the first things that made me conclude that devops was about pushing sysadmin skills on unprepared developers. /rant
setfacl -m u:NON-OWNER:rwX,d:u:NON-ONWER:rwX,d:u:OWNER:rwX DIR
(Allows NON-OWNER to read, write, execute if already executable for anyone to that directory, and allows NON-OWNER and OWNER to do the same for newly created files.)The default ACLs make sure that any newly created files can be accessed by both users.