The fileperms() function returns the permissions for a file or directory.
PHP fileperms() Function has the following syntax.
fileperms(filename)
Parameter | Is required | Description |
---|---|---|
filename | Required. | File to check |
This function returns the permission as a number on success or FALSE on failure.
The result of this function are cached. Use clearstatcache() to clear the cache.
Get the file permission
<?php
echo fileperms("test.txt");
?>
The code above generates the following result.
Display permissions as an octal value:
<?php
echo substr(sprintf("%o",fileperms("test.txt")),-4);
?>
The code above generates the following result.