Home > Backend Development > PHP Tutorial > php获取文件类型和文件信息的方法_php技巧

php获取文件类型和文件信息的方法_php技巧

WBOY
Release: 2016-05-16 20:11:13
Original
993 people have browsed it

本文实例讲述了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;>

Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template