: This article describes how to generate HTML files in PHP. For more information about PHP tutorials, see.
Most file functions have been used before. Here are just a few important ones:
Resource fopen (string $ filename, string $ mode [, bool $ use_include_path = false [, resource $ context]) // open the file, which has read-only, write-only, and read/write modes
Int filesize (string $ filename) // get the file size
Int fwrite (resource $ handle, string $ string [, int $ length]) // write a file
String fread (resource $ handle, int $ length) // read a binary file.
Bool unlink (string $ filename [, resource $ context]) // delete an object
More details: http://php.net/
Simple type:
Multiple files are generated cyclically, and 3 htm files are generated using 3 txt files (equivalent to conversion ):
Problems:
Warning: fopen (michael jordan--killer .htm): failed to open stream: Invalid argument
Encoding problem. The generated file is indeed successful, but the file name is garbled, so the returned result does not have a path. Change to English.
$ Value) {$ filename = $ value [0]; $ title = $ value [1]; $ fp = fopen ($ filename, "r "); $ get = fread ($ fp, filesize ($ filename); $ fp = fopen ($ title, "w"); fwrite ($ fp, $ get ); unlink ($ filename); // delete the source file} fclose ($ fp);?>
If you really want to name the htm file in Chinese, you can encode the php file into an ASCII code:
$ Value) {$ filename = $ value [0]; $ title = $ value [1]; $ fp = fopen ($ filename, "r "); $ get = fread ($ fp, filesize ($ filename); $ fp = fopen ($ title, "w"); fwrite ($ fp, $ get ); // unlink ($ filename); // delete the source file} fclose ($ fp);?>
The above section describes how to generate HTML files in PHP, including related content, and hope to help those who are interested in PHP tutorials.