PHP fileperms() Function
In this chapter you will learn:
- Definition for PHP fileperms() Function
- Syntax for PHP fileperms() Function
- Parameter for PHP fileperms() Function
- Return for PHP fileperms() Function
- Note for PHP filemtime() Function
- Example - Get the file permission
- Example - Display permissions as an octal value
Definition
The fileperms() function returns the permissions for a file or directory.
Syntax
PHP fileperms() Function has the following syntax.
fileperms(filename)
Parameter
Parameter | Is required | Description |
---|---|---|
filename | Required. | File to check |
Return
This function returns the permission as a number on success or FALSE on failure.
Note
The result of this function are cached. Use clearstatcache() to clear the cache.
Example 1
Get the file permission
<?php
echo fileperms("test.txt");
?>
The code above generates the following result.
Example 2
Display permissions as an octal value:
<?php
echo substr(sprintf("%o",fileperms("test.txt")),-4);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP filesize() Function
- Syntax for PHP filesize() Function
- Parameter for PHP filesize() Function
- Return for PHP filesize() Function
- Note for PHP filesize() Function
- Example - returns its filesize in bytes
Home » PHP Tutorial » PHP File Functions