Žel*_*vić 20
使用fileperms()函数
clearstatcache();
echo substr(sprintf('%o', fileperms('/etc/passwd')), -4);
Run Code Online (Sandbox Code Playgroud)
Hup*_*pie 12
您可以使用is_readable(),is_executable()等..命令.
真正的编码器使用按位运算,而不是字符串;)这是处理权限的更优雅方式:
function checkPerms($path)
{
clearstatcache(null, $path);
return decoct( fileperms($path) & 0777 );
}
Run Code Online (Sandbox Code Playgroud)