发布:thebaby 来源:net 【大 中 小】本文分享三例php代码,学习下php处理文件的创建时间、修改时间以及访问时间的方法,学习下filectime、filemtime、filteatime的用法。有需要的朋友参考下。 1,php文件的创建时间的例子 复制代码代码示例: <html> <head> <title>文件的创建时间-www.</title> </head> <body> <?php $file = "test.txt"; outputFileTestInfo( $file ); function outputFileTestInfo( $f ){ if ( ! file_exists( $f ) ){ print "$f does not exist<BR>"; return; } print "$f 创建于:".date( "D d M Y g:i A", filectime( $f ) )."<br>"; } ?> </body> </html> 2,php文件的修改时间 复制代码代码示例: <html> <head> <title>文件的修改时间-www.</title> </head> <body> <?php $file = "test.txt"; outputFileTestInfo( $file ); function outputFileTestInfo( $f ){ if ( ! file_exists( $f ) ){ print "$f does not exist<BR>"; return; } print "$f 修改于:".date( "D d M Y g:i A", filemtime( $f ) )."<br>"; } ?> </body> </html> 3,php文件的最后访问时间 复制代码代码示例: <html> <head> <title>文件的最后访问地时间-www.</title> </head> <body> <?php $file = "test.txt"; outputFileTestInfo( $file ); function outputFileTestInfo( $f ){ if ( ! file_exists( $f ) ){ print "$f does not exist<BR>"; return; } print "$f 最后访问时间为:".date( "D d M Y g:i A", fileatime( $f ) )."<br>"; } ?> </body> </html> |
|