PHP中的fileatime()函數是一個內置函數,用於返回指定文件的最後訪問時間。 fileatime()函數以Unix時間戳記成功返回文件的最後訪問時間,失敗則返回False。
文件名作為參數傳遞給fileatime()函數。將緩存fileatime()函數的結果,並使用一個名為clearstatcache()的函數來清除緩存。
用法:
fileatime($filename)
參數:PHP中的fileatime()函數僅接受一個參數$filename。它指定您要檢查其最後訪問時間的文件。
返回值:如果成功,它將返回文件的最後訪問時間作為Unix時間戳,如果失敗則返回False。
錯誤與異常:
- 時間分辨率可能因一個文件係統而異。
- 在某些禁用訪問時間更新以提高性能的Unix係統上,此函數不起作用。
例子:
Input : echo fileatime("gfg.txt"); Output : 1525159574 Input : echo "Last accessed: ".date("F d Y H:i:s.", fileatime("gfg.txt")); Output : Last accessed: May 1 2018 07:26:14.
以下示例程序旨在說明fileatime()函數。
程序1::
<?php
// checking last accessed time of a file
echo fileatime("gfg.txt");
?>
輸出:
1525159574
程序2::
<?php
// checking last accessed time of a file
echo fileatime("gfg.txt");
//checking last accessed time of a file
// and formatting the output of the date
echo "Last accessed: ".date("F d Y H:i:s.",
fileatime("gfg.txt"));
?>
輸出:
1525159574 Last accessed: May 1 2018 07:26:14.
參考:
http://php.net/manual/en/function.fileatime.php
相關用法
- PHP tan( )用法及代碼示例
- d3.js d3.max()用法及代碼示例
- PHP pi( )用法及代碼示例
- PHP each()用法及代碼示例
- CSS hsl()用法及代碼示例
- p5.js value()用法及代碼示例
- p5.js max()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- p5.js int()用法及代碼示例
- p5.js nfp()用法及代碼示例
- d3.js d3.min()用法及代碼示例
- p5.js nfc()用法及代碼示例
注:本文由純淨天空篩選整理自Shubrodeep Banerjee大神的英文原創作品 PHP | fileatime() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。