The chown() function can be used in php to modify the owner of the file. This function can change the owner of the specified file. If the modification is successful, it returns TRUE, if it fails, it returns FALSE; the syntax format is "chown(file ,owner)", the parameter owner specifies the new owner, which can be the user name or user ID.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use chown () function to modify the owner of the file.
chown — Change the owner of a file, returning TRUE on success or FALSE on failure.
Syntax
chown(file,owner)
Parameters | Description |
---|---|
file | Required. Specifies the documents to be checked. |
owner | Required. Provide new owner. Can be a username or the user's ID. |
Example: Change file owner and user group
Note:
The chown() function cannot operate on remote files. The file being checked must be accessible through the server's file system.
When safe mode is enabled, PHP will check whether the file or directory being operated on has the same UID (owner) as the script being executed.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to change file owner in php. For more information, please follow other related articles on the PHP Chinese website!