PHP Function Chown
The php function chown allows you to change the file owner on local files. It is a very useful function if you are running your website on a Unix environment, because PHP will always run as the same user as the Web server or command-line user (if used). That means that the user must have access to write and delete the web files in the directory to work with the scripts. Without proper permissions the application may have trouble working with files, whereas too many permissions can make your system vulnerable to hackers.
The function takes as argument the file name and the new owner, which can be either a user name or a numeric UID. If the user is followed by a colon and a group name, the group ownership of the file will also be changed. The chown function returns TRUE if successful and FALSE otherwise.
Unlike chgrp and chmod, changing the owner of a file is not something that can be done by any user, it requires superuser privileges to do so. It is also not recommended that you change the owner of the root folder of your system, it could allow somebody to change anything on the entire system. It is recommended that you use chown on a per-directory basis rather than on the whole filesystem. The chown function is not available for remote files because you would need to be able to get the full path of the file.