: This article mainly introduces php file reading and writing. if you are interested in the PHP Tutorial, you can refer to it. Get file information:
// Open the file $ file_path = "test.txt"; // Obtain the file information if ($ fp = fopen ($ file_path, "r ")) {$ file_info = fstat ($ fp); echo"";print_r($file_info);echo "
"; Echo"
The file size is {$ file_info ['size']} "; echo"
Last file modification time ". date (" Y-m-d H: I: s ", $ file_info ['mtime']); echo"
Last file access time ". date (" Y-m-d H: I: s ", $ file_info ['atime ']); echo"
Last File change time ". date (" Y-m-d H: I: s ", $ file_info ['ctime']);} else {echo" failed to open the file! ";}// Close the file fclose ($ fp );
". Filesize ($ file_path); echo"
". Date (" Y-m-d H: I: s ", fileatime ($ file_path); echo"
". Filectime ($ file_path); echo"
". Filemtime ($ file_path);?>
Read file information:
"; $ Content = str_replace (" \ r \ n ","
", $ Content); echo $ content;} else {echo" file does not exist ";} // close the file fclose ($ fp);?>
A simple way to read file information:
", $ Contents); echo $ contents;?>
The above introduces php reading and writing files, including the content, hope to be helpful to friends who are interested in PHP tutorials.