Issue
I need to get the permission of a file in Unix system in PHP. I tried stat()
and fileperms()
methods but both returns something like 33188
,16877
. But I am expecting the permission values like 755
,777
etc.
Solution
You may use fileperms()
function here:
clearstatcache();
echo substr(sprintf('%o', fileperms('demo')), -4);//0775
echo substr(sprintf('%o', fileperms('phptest/PHP_test')), -4);//0775
As suggested by Ravi Hirani's answer you may use
is_readable()
, is_executable()
etc. commands.
Answered By - Shashank Shah