stat() 函數可以返回有關文件的信息。
用法
array stat ( string $filename )
該函數可以收集以文件名命名的文件的統計信息。如果文件名是符號鏈接,則統計信息來自文件本身,而不是符號鏈接。 lstat() 函數與 stat() 函數相同,隻是它可以基於符號鏈接狀態。
示例1
<?php
$stat = stat("/PhpProject/sample.txt"); // Get file stat
echo "Acces time:" .$stat["atime"]; // Print file access time, this is the same as calling fileatime()
echo "\nModification time:" .$stat["mtime"]; //Print file modification time, this is the same as calling filemtime()
echo "\nDevice number:" .$stat["dev"]; // Print the device number
?>
輸出
Acces time:1590217956 Modification time:1591617832 Device number:1245376677
示例2
<?php
$stat = stat("/PhpProject/sample.txt");
if(!$stat) {
echo "stat() call failed...";
} else {
$atime = $stat["atime"] + 604800;
if(!touch("/PhpProject1/sampl2.txt", time(), $atime)) {
echo "failed to touch file...";
} else {
echo "touch() returned success...";
}
?>
輸出
touch() returned success...
相關用法
- PHP stat()用法及代碼示例
- 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 - Function stat()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。