PHP fileowner() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The fileowner() is an inbuilt function in PHP that returns the details for the file owner. Syntax: fileowner(string $filename): int|falseParameters: This function accepts a single parameter: filename: This parameter specifies the file path for the specific file.Name of the file. Return Value: The user id of the owner will be returned by this function in case of true, otherwise, false on failure. The user id will be returned in numerical format. The posix_getpwuid() function will be used in order to resolve it to a username. Error: An E_WARNING will be emitted, upon failure. Example 1: The following code demonstrates the fileowner() function. PHP <?php $filename = "text.txt" ; print_r(posix_getpwuid(fileowner($filename))); ?> Output: Array ( [name] => dachman [passwd] => x [uid] => 1000 [gid] => 1000 [gecos] => dachman,,, [dir] => /home/dachman [shell][/shell] => /usr/bin/zsh ) Example 2: The following code demonstrates the fileowner() function. PHP <?php $filename = "text.txt" ; print_r(fileowner($filename)); ?> Output: 1000 Reference: https://www.php.net/manual/en/function.fileowner.php Comment More infoAdvertise with us Next Article PHP fileinode() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Filesystem Similar Reads PHP | fileperms( ) Function The fileperms() function in PHP is an inbuilt function which is used to return the permissions given to a file or a directory. The filename of the file whose permissions have to be checked is sent as a parameter to the function and it returns the permissions given to the file in the form of numbers 2 min read PHP fileinode() Function The fileinode() function is an inbuilt function in PHP that returns the inode of the file. Syntax: fileinode(string $filename): int|falseParameter: This function has only one parameter: filename: This parameter specifies the path for the particular file.Return Value: This function returns the inode 1 min read PHP fclose() Function The fclose() function in PHP closes a file that was previously opened by fopen(). Closing a file releases the resource associated with it and makes sure all the data written to the file is properly saved. Not closing files can lead to resource leaks or incomplete data writing.Syntax:bool fclose(reso 2 min read PHP filegroup() Function The filegroup() is an inbuilt function in PHP that returns the filegroup. This function returns a group id that can resolve using posix_getgrigid() to a name. Syntax: filegroup(string $filename): int|falseParameter: This function has only one parameter. filename: A name of the file or path of the fi 1 min read PHP | dir() Function The dir() function in PHP is an inbuilt function which is used to return an instance of the Directory class. The dir() function is used to read a directory, which includes the following: The given directory is opened. The two properties handle and path of dir() are available. Both handle and path pr 2 min read PHP | closedir( ) Function The closedir() function in PHP is an inbuilt function which is used to close a directory handle. The directory handle to be closed is sent as a parameter to the closedir() function and the closedir() closes the directory handle. The directory handle must be previously opened by the opendir() functio 2 min read Like