chown
chown
Changes file owner
bool **chown** string $filename $user
Attempts to change the owner of the file
to user . Only the superuser may change the
owner of a file.
filename``user
filenamePath to the file.
userA user name or number.
return.success
Voorbeeld: Simple usage
<?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']));
?>
Array
(
[name] => root
[passwd] => x
[uid] => 0
[gid] => 0
[gecos] => root
[dir] => /root
[shell] => /bin/bash
)
Opmerking: > On Windows, this function fails silently when applied on a regular file.
chmod``chgrp