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 CURL获取返回值的方法

在CURL中有一个参数 CURLOPT_RETURNTRANSFER :复制代码 代码如下:curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);默认是...

PHP动态页生成静态页的3种常用方法

生成静态页的页面非常的简单就是定义好模板与模板标题,之后利用str_replace进行替换了,是最常用的方法,另一种是利用ob_get_contents输出获得然后生成html,还有一种...

php生成excel文件的简单方法

php生成excel文件的简单方法

生成excel 当然使用的是 phpExcel这个类库了,可是它太麻烦了,对于只要简单生成来说有点不值得 什么叫简单,把数据库的数据导入到excel就行了, 这个就是简单了 下面看一段代...

php若干单维数组遍历方法的比较

复制代码 代码如下: <?php //a $arr=array('a'=>'abc','b'=>123,'c'=>true); //b //$arr=range(...

php中的时间显示

 方法1:  //list($first,$second)=explode(" ",$date_temp);     ...