fileperms() function in PHP


The fileperms() function returns the permissions of a file. It returns permission as a number on success, else returns FALSE on failure.

Syntax

fileperms(file_path)

Parameters

  • file_path − The path of the file to be checked.

Return

The fileperms() function returns permission as a number on success, else returns FALSE on failure.

Example

<?php
   echo fileperms("new.txt");
?>

Output

33206

Let us see another example that displays permission as octal value.

Example

<?php
   echo substr(sprintf('%o', fileperms(two.txt')), -4);
?>

Output

0666

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 24-Jun-2020

57 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements