Chown
(PHP 4 and PHP 5)
Chown-change the file owner
Description
Boolean chown (string $ file name, mixed $ user)
Attempt to change the owner file of an archive to the user. Only the Supervisor can change the human Archive.
Parameters
File name
File path.
User
User name or number.
Return value
Returns TRUE or FALSE.
Instance
<? Php
// File name and username to use
$ File_name = "foo. php ";
$ Path = "/home/sites/php.net/public_html/sandbox". $ file_name;
$ User_name = "root ";
// Set the user
Chown ($ path, $ user_name );
// Check the result
$ Stat = stat ($ path );
Print_r (posix_getpwuid ($ stat ['uid']);
?>
The above example will output something similar:
Array (7 ){
["Name"] =>
String (13) "php.net"
["Passwd"] =>
String (1) "x"
["Uid"] =>
Int (148864)
["Gid"] =>
Int (148910)
["Gecos"] =>
String (13) "php.net"
["Dir"] =>
String (25) "/home/sites/php.net"
["Shell"] =>
String (13) "/sbin/nologin"
}
Webmaster recommendation:
PHP online manual