Home > Article > Backend Development > How to get file type and file information in php, _PHP tutorial
The example in this article describes the method of obtaining file type and file information in php. Share it with everyone for your reference. The specific implementation method is as follows:
<?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"]); ?>
I hope this article will be helpful to everyone’s PHP programming design.