stat() 函數返回有關文件的信息。
Note −stat() 函數的結果因服務器而異。
該函數返回一個包含以下給定元素的數組。
- [0] 或 [dev] - 設備編號
- [1] 或 [ino] - Inode 編號
- [2] 或 [mode] - inode 保護模式
- [3] 或 [nlink] - 鏈接數
- [4] 或 [uid] - 所有者的用戶 ID
- [5] 或 [gid] - 所有者的組 ID
- [6] 或 [rdev] - Inode 設備類型
- [7] 或 [size] - 大小(以字節為單位)
- [8] 或 [atime] - 上次訪問時間作為 Unix 時間戳
- [9] 或 [mtime] - 上次修改時間作為 Unix 時間戳
- [10] 或 [ctime] - 上次 inode 更改時間作為 Unix 時間戳
- [11] 或 [blksize] - 文件係統 IO 的塊大小
- [12] 或 [blocks] - 分配的塊數
用法
stat(file_path)
參數
file_path −要檢查的文件的路徑。
返回
lstat() 函數返回上麵顯示的元素。
示例
<?php
print_r(stat("demo.txt"));
?>
輸出
Array ( [0] => 0 [1] => 0 [2] => 33206 [3] => 1 [4] => 0 [5] => 0 [6] => 0 [7] => 120 [8] => 17128173529 [9] => 1984185875 [10] => 1294322653 [11] => -1 [12] => -1 [dev] => 0 [ino] => 0 [mode] => 33206 [nlink] => 1 [uid] => 0 [gid] => 0 [rdev] => 0 [size] => 120 [atime] => 1718173529 [mtime] => 1984185875 [ctime] => 1294322653 [blksize] => -1 [blocks] => -1 )
讓我們再看一個例子。
示例
<?php
$stat = stat('new.txt');
echo 'File mode = ' .$stat['mode'];
echo '<br />Last Modification time of the file = ' .$stat['mtime'];
?>
輸出
File mode = 33206 Last Modification time of the file = 1241387935
相關用法
- PHP stat( )用法及代碼示例
- PHP stats_dens_pmf_binomial()用法及代碼示例
- PHP stats_cdf_chisquare()用法及代碼示例
- PHP stats_cdf_t()用法及代碼示例
- PHP stats_rand_gen_iuniform()用法及代碼示例
- PHP stats_cdf_exponential()用法及代碼示例
- PHP stats_harmonic_mean()用法及代碼示例
- PHP stats_cdf_normal()用法及代碼示例
- PHP stats_rand_gen_ipoisson()用法及代碼示例
- PHP stats_dens_laplace()用法及代碼示例
- PHP stats_cdf_poisson()用法及代碼示例
- PHP stats_rand_gen_beta()用法及代碼示例
- PHP stats_standard_deviation()用法及代碼示例
- PHP stats_stat_binomial_coef()用法及代碼示例
- PHP stats_cdf_beta()用法及代碼示例
- PHP stats_stat_factorial()用法及代碼示例
- PHP stats_stat_percentile()用法及代碼示例
- PHP stats_rand_gen_chisquare()用法及代碼示例
- PHP stats_stat_correlation()用法及代碼示例
- PHP stats_dens_cauchy()用法及代碼示例
注:本文由純淨天空篩選整理自Samual Sam大神的英文原創作品 stat() function in PHP。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。