PHP fileowner() Function
Definition
The fileowner() function returns the user ID (owner) of the specified file.
Syntax
PHP fileowner() Function has the following syntax.
fileowner(filename)
Parameter
Parameter | Is Required | Description |
filename | Required. | File to check |
Return
This function returns the user ID on success or FALSE on failure.
Note
Use posix_getpwuid() to convert the user ID to a user name.
The result of this function are cached. Use clearstatcache() to clear the cache.
This function doesn't produce meaningful results on Windows systems.
Example
To read the owner of a file, use the fileowner() function, which takes a filename and returns the ID of the file's owner.
<?PHP// w w w . j a v a 2 s . c o m
$owner = fileowner("test.txt");
if ($owner != 0) {
print "Warning: /etc/passwd isn't owned by root!";
}
echo fileowner("test.txt");
?>
The code above generates the following result.