Definition :
The chown() function in PHP is an inbuilt function.The PHP chown() function attempts to change the owner of the specified file. Only the superuser may change the owner of a file.
chown(file, owner)
Parameter | Description |
---|---|
file | Required. Specifies the path to the file to change owner for |
owner | Required. Specifies the new owner. Can be a user name or a user ID. |
Errors And Exception:
Lets assume that we have a file called test.txt in the current working directory. The example below demonstrates on using this function to change its owner.
Output :
Array
(
[name] => root
[passwd] => x
[uid] => 0
[gid] => 0
[gecos] => root
[dir] => /root
[shell] => /bin/bash
)