PHP file programming (1)

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.