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

yipeiwu_com5年前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;
}

相关文章

使用ucenter实现多站点同步登录的讲解

做Web开发经常会要求实现多站点同步登录的情况,对于PHP开发来说,我们可以使用ucenter来实现多个站点同时登陆同时退出,用户同步的功能。下面我们一起看一下ucenter是如何实现同...

php数组函数序列 之array_count_values() 统计数组中所有值出现的次数函数

array_count_values()定义和用法 array_count_values() 函数用于统计数组中所有值出现的次数。 本函数返回一个数组,其元素的键名是原数组的值,键值是该...

php调用自己java程序的方法详解

本文实例讲述了php调用自己的java程序实现方法。分享给大家供大家参考,具体如下: 最开始要装jdk这个就不用说了,我装的是java ee 5+jdk 1.把下载的php-java-b...

PHP判断文件是否被引入的方法get_included_files用法示例

本文实例讲述了PHP判断文件是否被引入的方法get_included_files用法。分享给大家供大家参考,具体如下: <?php // 本文件是 abc.php in...

浅谈php调用python文件

浅谈php调用python文件

关于PHP调用Python数据传输问题 这是以前大学时做项目出现的问题,现在把它挪上来,希望给遇到问题的未来大佬给出一些小的思路,请大佬们不要大意的帮我改正,如果出现问题或者有更好的解决...