PHP 4, PHP 5, PHP 7, PHP 8
fileperms - Gets file permissions
Code Examples

fileperms( string$filename ): int|false

Gets permissions for the given file.



Path to the file.

Return Values

Returns the file's permissions as a numeric mode. Lower bits of this mode are the same as the permissions expected by chmod, however on most platforms the return value will also include information on the type of file given as filename. The examples below demonstrate how to test the return value for specific permissions and file types on POSIX systems, including Linux and macOS.

For local files, the specific return value is that of the st_mode member of the structure returned by the C library's stat function. Exactly which bits are set can vary from platform to platform, and looking up your specific platform's documentation is recommended if parsing the non-permission bits of the return value is required.

Returns false on failure.

Exceptions and Errors

Upon failure, an E_WARNING is emitted.



The results of this function are cached. See clearstatcache for more details.

As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to to determine which wrappers support stat family of functionality.

Related Functions

Example of fileperms

Show all examples for fileperms

PHP Version: