Home >php教程 >PHP源码 >php获取文件类型和文件信息操作

php获取文件类型和文件信息操作

PHP中文网
PHP中文网Original
2016-06-01 14:33:121234browse

php代码

<?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"]);
?>
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