您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/3/5 21:58:57发布21次查看
php将fileterms函数返回的结果变成可读的形式,如: rwx--rx--x
代码如下:
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;
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product