PHP fileperms() Function

Definition

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

Syntax

PHP fileperms() Function has the following syntax.

fileperms(filename)

Parameter

ParameterIs requiredDescription
filenameRequired.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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions