A small message book instance for PHP file operations ,. An example of a small message book for PHP file operations. this example describes a small message book for PHP file operations. Share it with you for your reference. The details are as follows: Index. php file: php $ p php file operations for small message book instances,
This example describes the small message book for PHP file operations. Share it with you for your reference. The details are as follows:
The Index. php file is as follows:
<? Php $ path = "DB/"; // define the path $ dr = opendir ($ path); // open the directory while ($ filen = readdir ($ dr )) // cyclically read the files in the directory {if ($ filen! = "." And $ filen! = "..") {$ Fs = fopen ($ path. $ filen, "r"); echo"Title:". Fgets ($ fs )."
"; Echo"Author:". Fgets ($ fs )."
"; Echo"Content:".fread($fs, filesize($path.$filen))."
"; Echo" "; fclose ($ fs) ;}} closedir ($ dr) // Close the directory?>
The Post. php file is as follows:
<? Php $ path = "DB/"; $ filename = "S ". date ("YmdHis "). ". dat "; $ fp = fopen ($ path. $ filename, "w"); fwrite ($ fp, $ _ POST ["title"]. "/n"); fwrite ($ fp, $ _ POST ["author"]. "/n"); fwrite ($ fp, $ _ POST ["content"]. "/n"); fclose ($ fp); echo "message published successfully! "; Echo" back to homepage ";?>
Post new messages
Post new messages
I hope this article will help you with php programming.
Example: a small message book for PHP file operations. Share it with you for your reference. The Index. php file is as follows: php $ p...