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

ParameterIs RequiredDescription
filenameRequired.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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions