PHP fileperms() Function

❮ PHP Filesystem Reference

Example

Return the file permissions for "test.txt":

<?php
echo fileperms("test.txt");
?>
Run Example »

Definition and Usage

The fileperms() function returns the permissions for a file.

Note: The result of this function is cached. Use clearstatcache() to clear the cache.

Syntax

fileperms(filename)

Parameter Values

Parameter Description
filename Required. Specifies the path to the file to check


Technical Details

Return Value: The file's permissions as a number, FALSE on failure
PHP Version: 4.0+

More Examples

Example

Display permissions as an octal value:

<?php
echo substr(sprintf("%o",fileperms("test.txt")),-4);
?>
Run Example »

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.