Home  >  Article  >  Backend Development  >  How to get file type and file information in php

How to get file type and file information in php

WBOY
WBOYOriginal
2016-07-25 08:44:47948browse

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:

  1. $file = "php.txt";
  2. //Open the file, r means open in read-only mode
  3. $handle = fopen($file,"r");
  4. //Get File statistics
  5. $fstat = fstat($handle);
  6. echo "File name: ".basename($file)."
    ";
  7. //echo "File size: ".round(filesize(" $file")/1024,2)."kb
    ";
  8. echo "File size:".round($fstat["size"]/1024,2)."kb
    ";
  9. // echo "Last access time:".date("Y-m-d h:i:s",fileatime($file))."
    ";
  10. echo "Last access time:".date("Y-m-d h:i: s",$fstat["atime"])."
    ";
  11. //echo "Last modified time:".date("Y-m-d h:i:s",filemtime($file))."< ;br>";
  12. echo "Last modified time:".date("Y-m-d h:i:s",$fstat["mtime"]);
  13. ?>
Copy code

I hope this article will be helpful to everyone’s PHP programming design.

php


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