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;
}

相关文章

PHP技术开发技巧分享

1. 提高PHP的运行效率   PHP的优点之一是速度很快,对于一般的网站应用,可以说是已经足够了。不过如果站点的访问量很高、带宽窄或者其它的因素令服务器产生性能瓶颈的时候,你可能得想想...

Windows上php5.6操作mongodb数据库示例【配置、连接、获取实例】

Windows上php5.6操作mongodb数据库示例【配置、连接、获取实例】

本文实例讲述了Windows上php5.6操作mongodb数据库的方法。分享给大家供大家参考,具体如下: 一、配置 针对不同线程安全、VC版本的 PHP 发行版,可从 PECL 获取到...

PHP比较运算符的详细介绍

比较运算符种类 如同它们名称所暗示的,允许对两个值进行比较。比较运算符有如下几个: 1) $a > $b 大于:如果 $a 严格大于$b,则返回TRUE 2) $a < $b...

php中bind_param()函数用法分析

php中bind_param()函数用法分析

本文实例讲述了php中bind_param()函数用法。分享给大家供大家参考,具体如下: 从字面上不难理解,绑定的参数;下面我通过一个绑定参数的例子讲一下: for example: b...

PHP @ at 记号的作用示例介绍

看PHP的代码,总有些行前边有@符号,一直不知道是什么意思。 例如dede5.7 @ni=imagecreatetruecolor(ftoW,$ftoH); 今天用到了,就记一下吧。其实...