PHP chown() Function
Definition
The chown() function changes the owner of the specified file.
Syntax
PHP chown() Function has the following syntax.
chown(file,owner)
Parameter
Parameter | Is Required | Description |
---|---|---|
file | Required. | File to check |
owner | Required. | New owner. Can be a user name or a user ID. |
Return
PHP chown() Function returns TRUE on success and FALSE on failure.
Example
chown() attempts to change the file to be owned by the user. On success, true is returned; otherwise, false.
The second parameter can either be a username or a user ID number.
<?PHP// ww w. j a v a 2s .c o m
if (chown("myfile.txt", "tom")) {
print "File owner changed.\n";
} else {
print "File ownership change failed!\n";
}
chown("test.txt","Jack");
?>
The code above generates the following result.