Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

fileperms()

Example

Please provide the “test.txt” file permissions back:

<?php
echo fileperms(“test.txt”);
?>

Definition and Usage

The permissions for a file are returned by the fileperms() method.

 

Note: This function caches its output. To clear the cache, use clearstatcache().

Syntax

fileperms(filename)

Parameter Values

 

Parameter

Description

filename

Essential. gives the location of the file to be checked.

Technical Details

Return Value:

Permissions for the file as a number; if not granted, FALSE

PHP Version:

4.0+

More Examples

Example

Permissions are shown as an octal value:

<?php
echo substr(sprintf(“%o”,fileperms(“test.txt”)),-4);
?>