php將fileterms函數(shù)返回的結(jié)果變成可讀的形式
更新時(shí)間:2011年04月21日 23:47:26 作者:
php將fileterms函數(shù)返回的結(jié)果變成可讀的形式,如: rwx--rx--x
復(fù)制代碼 代碼如下:
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;
}
相關(guān)文章
php數(shù)組函數(shù)序列之a(chǎn)rray_keys() - 獲取數(shù)組鍵名
array_keys() 函數(shù)返回包含數(shù)組中所有鍵名的一個(gè)新數(shù)組。如果提供了第二個(gè)參數(shù),則只返回鍵值為該值的鍵名2011-10-10PHP取二進(jìn)制文件頭快速判斷文件類型的實(shí)現(xiàn)代碼
以下代碼就展示了自己通過讀取文件頭信息來識(shí)別文件的真實(shí)類型。需要的朋友可以過來參考下2013-08-08WordPress開發(fā)中用于獲取近期文章的PHP函數(shù)使用解析
這篇文章主要介紹了WordPress開發(fā)中用于獲取近期文章的PHP函數(shù)使用解析,即對(duì)wp_get_recent_posts函數(shù)的使用方法介紹,需要的朋友可以參考下2016-01-01php版本CKEditor 4和CKFinder安裝及配置方法圖文教程
這篇文章主要介紹了php版本CKEditor 4和CKFinder安裝及配置方法,結(jié)合圖文與實(shí)例形式詳細(xì)分析了php安裝及配置CKEditor 4和CKFinder相關(guān)實(shí)現(xiàn)步驟、操作技巧與注意事項(xiàng),需要的朋友可以參考下2019-06-06靜態(tài)html文件執(zhí)行php語(yǔ)句的方法(推薦)
下面小編就為大家?guī)硪黄o態(tài)html文件執(zhí)行php語(yǔ)句的方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11PHP7安裝Redis擴(kuò)展教程【Linux與Windows平臺(tái)】
這篇文章主要介紹了PHP7安裝Redis擴(kuò)展的方法,簡(jiǎn)單分析了Linux與Windows平臺(tái)Redis擴(kuò)展的安裝方法,并提供了一個(gè)實(shí)例進(jìn)一步分析了php操作Redis的相關(guān)技巧,需要的朋友可以參考下2016-09-09gearman中任務(wù)的優(yōu)先級(jí)和返回狀態(tài)實(shí)例分析
這篇文章主要介紹了gearman中任務(wù)的優(yōu)先級(jí)和返回狀態(tài),結(jié)合實(shí)例形式分析了gearman任務(wù)的優(yōu)先級(jí)以及獲取返回狀態(tài)相關(guān)操作技巧,需要的朋友可以參考下2020-02-02