PHP chown() Function
In this chapter you will learn:
- Definition for PHP chown() Function
- Syntax for PHP chown() Function
- Parameter for PHP chown() Function
- Return for PHP chown() Function
- Example - changes the owner of the specified file
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//from j a v a2 s .co 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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP chroot() Function
- Syntax for PHP chroot() Function
- Parameter for PHP chroot() Function
- Return for PHP chroot() Function
- Note for PHP chroot() Function
- Example - Change the root directory
Home » PHP Tutorial » PHP File Functions