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简单构造json多维数组的方法示例

本文实例讲述了php简单构造json多维数组的方法。分享给大家供大家参考,具体如下: php构造json多维数组其实很简单 下面列举了将mysqli的查询结果数组序列化为json的php...

PHP利用递归函数实现无限级分类的方法

相信很多学php的很多小伙伴都会尝试做一个网上商城作为提升自己技术的一种途径。各种对商品分类,商品名之类的操作应该是得心应手,那么就可以尝试下无限级分类列表的制作了。 什么是无限级分类?...

PHP中date与gmdate的区别及默认时区设置

一、date与gmdate有什么区别?PHP时间函数中有两个格式化函数:date()和gmdate(),在官方的文档中的描述为:复制代码 代码如下:date()  ...

通过chrome浏览器控制台(Console)进行PHP Debug的方法

通过chrome浏览器控制台(Console)进行PHP Debug的方法

 效果如下图 PHP Console是一款可以帮助用户模拟真实的PHP网站运行环境,帮助用户使用Chrome插件对PHP代码进行调试的Chrome插件,用户在Chrome中安...

php使用curl简单抓取远程url的方法

本文实例讲述了php使用curl抓取远程url的方法。分享给大家供大家参考。具体如下: cURL是一个非常有用的php库,可以用来连接不通类型的服务器和协议,下面是一个最基本的范例用来抓...