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预定义超全局数组变量小结

本文实例讲述了PHP预定义超全局数组变量。分享给大家供大家参考,具体如下: 1.PHP 预定义的超全局变量数组 特性: a.特殊的数组,操作方式没有区别 b.不用声明,php脚本中默认存...

几个实用的PHP内置函数使用指南

几个实用的PHP内置函数使用指南

PHP有许多内置函数,其中大多数函数都被程序员广泛使用。但也有一些函数隐藏在角落,本文将向大家介绍7个鲜为人知,但用处非常大的函数。 没用过的程序员不妨过来看看。   1.highli...

PHP自带ZIP压缩、解压缩类ZipArchiv使用指南

要使用该PHP扩展类,需要(PHP 5 >= 5.2.0, PECL zip >= 1.1.0),部分方法需要 PHP 5.2.+,且php.ini配置支持zip 对于wi...

PHP直接修改表内容DataGrid功能实现代码

PHP直接修改表内容DataGrid功能实现代码

由于需要连接Oracle所以从二次开发和页面样式来说个人觉得phpMyDataGrid还是比较好上手。 1. 创建测试数据库和表 create database `guru`;...

判断是否为指定长度内字符串的php函数

复制代码 代码如下: //———————————————————————————– // 函数名:CheckLengthBetween($C_char, $I_len1, $I_len2...