這篇文章主要介紹了php獲得文件大小和文件創建時間的方法,涉及php中filesize及fileatime函數的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了php獲得文件大小和文件創建時間的方法。分享給大家供大家參考。具體分析如下:
php中可以顯示文件的各種屬性,這些屬性包括文件的最后訪問時間、最后修改時間、文件大小等。
- <HTML>
- <HEAD>
- <TITLE>Returning information about a file</TITLE>
- </HEAD>
- <BODY>
- <?php
- print "The size of the file is ";
- print filesize( "samplefile.doc" );
- print "<br>";
- $atime = fileatime( "samplefile.doc" );
- print "This file accessed on ";
- print date("l, M d, Y g:i a", $atime);
- print "<br>";
- $mtime = filemtime( "samplefile.doc" );
- print "This file was modified on ";
- print date("l, M d, Y g:i a", $mtime);
- print "<br>";
- $ctime = filectime( "samplefile.doc" );
- print "This file was changed on ";
- print date("l, M d, Y g:i a", $ctime);
- ?>
- </BODY>
- </HTML>
希望本文所述對大家的php程序設計有所幫助。
新聞熱點
疑難解答