PHP fileperms()Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The fileperms() function returns the permissions of a file or directory.
If successful, the function returns the permissions as a number. If it fails, it returns FALSE.
Syntax
fileperms(filename)
| Parameter | Description |
|---|---|
| filename | Required. Specifies the file to check. |
Tips and Notes
Note:The results of this function are cached. Use clearstatcache() to clear the cache.
Example 1
<?php
echo fileperms("test.txt");
?>
echo fileperms("test.txt");
?>
The above code will output:
33206
Example 2
Display permissions as an octal value:
<?php
echo substr(sprintf("%o",fileperms("test.txt")),-4);
?>
echo substr(sprintf("%o",fileperms("test.txt")),-4);
?>
The above code will output:
1777
Complete PHP Filesystem Reference Manual Other Extensions