php8.5
Home/ Manual/ spl / splfileinfo/ SplFileInfo::getPerms

SplFileInfo::getPerms

PHP function Edit on GitHub ✎

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

Gets file permissions

Description

SplFileInfo::getPerms(): int|false

Gets the file permissions for the file.

Parameters Parameters

Return Values

Returns the file permissions on success, or false on failure.

Examples

SplFileInfo::getPerms() example

php
<?php
$info = new SplFileInfo('/tmp');
echo substr(sprintf('%o', $info->getPerms()), -4);

$info = new SplFileInfo(__FILE__);
echo substr(sprintf('%o', $info->getPerms()), -4);
?>

The above example will output something similar to:

output
1777
0644

Source: reference/spl/splfileinfo/getperms.xml · from the official PHP manual (php/doc-en)