Home  >  Article  >  Backend Development  >  php获取文件类型和文件信息的方法,_PHP教程

php获取文件类型和文件信息的方法,_PHP教程

WBOY
WBOYOriginal
2016-07-13 09:46:50777browse

php获取文件类型和文件信息的方法,

本文实例讲述了php获取文件类型和文件信息的方法。分享给大家供大家参考。具体实现方法如下:

<&#63;php
$file = "php.txt";
//打开文件,r表示以只读方式打开
$handle = fopen($file,"r");
//获取文件的统计信息
$fstat = fstat($handle);
echo "文件名:".basename($file)."<br>";
//echo "文件大小:".round(filesize("$file")/1024,2)."kb<br>";
echo "文件大小:".round($fstat["size"]/1024,2)."kb<br>";
//echo "最后访问时间:".date("Y-m-d h:i:s",fileatime($file))."<br>";
echo "最后访问时间:".date("Y-m-d h:i:s",$fstat["atime"])."<br>";
//echo "最后修改时间:".date("Y-m-d h:i:s",filemtime($file))."<br>";
echo "最后修改时间:".date("Y-m-d h:i:s",$fstat["mtime"]);
&#63;>

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1030142.htmlTechArticlephp获取文件类型和文件信息的方法, 本文实例讲述了php获取文件类型和文件信息的方法。分享给大家供大家参考。具体实现方法如下: p...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn