1. OperationCompositionTo obtain the file information.
<? PHP // Open a file $ File_path = " Text.txt " ; If ($ Fp = fopen ($ file_path, " R " )){ // Retrieve File Information $ File_info =Fstat ($ FP); echo " <PRE> " ; Print_r ($ file_info); echo " </PRE> " ; // Single fetch $ File_size = $ file_info [ ' Size ' ]; // The file size is calculated in bytes. Echo " The file size is: " . $ File_size; echo " <Br/> last file access time: " . Date ( " Y-m-d h: I: S " , $ File_info [ ' Atime ' ]); // Atime indicates the time when the file was last accessed] Echo " <Br/> last file modification time: " . Date ( " Y-m-d h: I: S " , $ File_info [ ' Mtime ' ]); // Mtime indicates the time when the last file content was modified] Echo " <Br/> last File Change Time: " . Date ( " Y-m-d h: I: S " , $ File_info [ ' Ctime ' ]); // Ctime indicates the time when the last file owner/file group was modified for the file] } Else {Echo " Opening the file failed. " ;} // Close the file. This is very important. Fclose ($ FP ); ?>
2. method 2 for obtaining File Information
<? PHP // Second, Get File Information $ File_path = " Text.txt " ; If (! File_exists ($ file_path) {echo " File does not exist " ; Exit ();} echo " <Br> " . Date ( " Y-m-d h: I: S " , Fileatime ($ file_path); echo " <Br> " . Date ( " Y-m-d h: I: S " , Filemtime ($ file_path); echo " <Br> " . Date ( " Y-m-d h: I: S " , Filectime ($ file_path )); // Echo "<br>". filemtime ($ file_path ); // Echo "<br>". filectime ($ file_path ); ?>