php将fileterms函数返回的结果变成可读的形式

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

function perms_str($perms){
    if (($perms & 0xC000) == 0xC000) {
        // Socket
        $info = 's';
    } elseif (($perms & 0xA000) == 0xA000) {
        // Symbolic Link
        $info = 'l';
    } elseif (($perms & 0x8000) == 0x8000) {
        // Regular
        $info = '-';
    } elseif (($perms & 0x6000) == 0x6000) {
        // Block special
        $info = 'b';
    } elseif (($perms & 0x4000) == 0x4000) {
        // Directory
        $info = 'd';
    } elseif (($perms & 0x2000) == 0x2000) {
        // Character special
        $info = 'c';
    } elseif (($perms & 0x1000) == 0x1000) {
        // FIFO pipe
        $info = 'p';
    } else {
        // Unknown
        $info = 'u';
    }

    // Owner
    $info .= (($perms & 0x0100) ? 'r' : '-');
    $info .= (($perms & 0x0080) ? 'w' : '-');
    $info .= (($perms & 0x0040) ?
                (($perms & 0x0800) ? 's' : 'x' ) :
                (($perms & 0x0800) ? 'S' : '-'));

    // Group
    $info .= (($perms & 0x0020) ? 'r' : '-');
    $info .= (($perms & 0x0010) ? 'w' : '-');
    $info .= (($perms & 0x0008) ?
                (($perms & 0x0400) ? 's' : 'x' ) :
                (($perms & 0x0400) ? 'S' : '-'));

    // World
    $info .= (($perms & 0x0004) ? 'r' : '-');
    $info .= (($perms & 0x0002) ? 'w' : '-');
    $info .= (($perms & 0x0001) ?
                (($perms & 0x0200) ? 't' : 'x' ) :
                (($perms & 0x0200) ? 'T' : '-'));

    return $info;
}

相关文章

PHP strripos函数用法总结

php strripos()函数 语法 作用:寻找某字符串中某字符最后出现的位置,不区分大小写 语法: strripos(string,find,start) 参数: string...

PHP防止sql注入小技巧之sql预处理原理与实现方法分析

本文实例讲述了PHP防止sql注入小技巧之sql预处理原理与实现方法。分享给大家供大家参考,具体如下: 我们可以把sql预处理看作是想要运行的 SQL 的一种编译过的模板,它可以使用变量...

PHP读取、解析eml文件及生成网页的方法示例

PHP读取、解析eml文件及生成网页的方法示例

本文实例讲述了PHP读取、解析eml文件及生成网页的方法。分享给大家供大家参考,具体如下: php读取eml实例,本实例可以将导出eml文件解析成正文,并且可以将附件保存到服务器。不多说...

php中OR与|| AND与&&的区别总结

php中OR与|| AND与&&的区别总结

本身没有区别,习惯问题 ,但是有时候牵涉到运算符优先级的问题,结果会不同,记录下。 例如: 复制代码 代码如下:$p = 6 or 0; var_dump($p);//int(6) $p...

PHP 多维数组排序实现代码

array_multisort (PHP 4, PHP 5) array_multisort -- 对多个数组或多维数组进行排序 说明 bool array_multisort ( ar...