PHP fileowner() Function
In this chapter you will learn:
- Definition for PHP fileowner() Function
- Syntax for PHP fileowner() Function
- Parameter for PHP fileowner() Function
- Return for PHP fileowner() Function
- Note for PHP filemtime() Function
- Example - Get the file owner
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/*from ja v a2s .com*/
$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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP fileperms() Function
- Syntax for PHP fileperms() Function
- Parameter for PHP fileperms() Function
- Return for PHP fileperms() Function
- Note for PHP filemtime() Function
- Example - Get the file permission
- Example - Display permissions as an octal value
Home » PHP Tutorial » PHP File Functions