1. 程式人生 > >php fileperms獲取檔案的許可權

php fileperms獲取檔案的許可權

php fileperms()函式用於獲取檔案或目錄的許可權,如果成功,fileperms函式以數字形式返回許可權,否則返回 FALSE,本文章向大家介紹fileperms函式的使用方法和例項,需要的朋友可以參考一下。

php fileperms函式介紹

fileperms() 函式返回檔案或目錄的許可權,如果成功,該函式以數字形式返回許可權,如果失敗,則返回 FALSE。該函式的結果會被快取。請使用 clearstatcache() 來清除快取。

語法:

int fileperms  ( string $filename  )

取得檔案的許可權。 

引數:

  1. filename  檔案的路徑。 

php fileperms函式例項

1.使用fileperms函式獲取檔案manongjc.txt的許可權:

<?php
/*  http://www.manongjc.com/article/1413.html */
echo fileperms("manongjc.txt");
?>

執行結果:

33206

2.獲取8進位制的許可權

<?php
   echo substr(base_convert(fileperms("/etc/passwd"), 10, 8), 3);
?>