Home >Backend Development >PHP Tutorial >PHP code example for reading and writing files to generate HTML

PHP code example for reading and writing files to generate HTML

WBOY
WBOYOriginal
2016-07-25 08:59:241135browse
  1. //Generate HTML
  2. $countfile="template.html";
  3. $num=file_get_contents($countfile);
  4. echo $num;
  5. $num=str_replace("|*|* |PAGE_TITLE|*|*|","myhome",$num);
  6. $path="template.html";
  7. $handle=fopen($path,"w"); //Open the news path in writing method
  8. fwrite($handle,$num); //Write the replaced content into the generated HTML file
  9. fclose($handle);
  10. ?>
Copy code

Instructions: file_get_contents -- Read the entire file into a string file -- read the entire file into an array

Detailed reference: php file_get_contents code to capture page information php file_get_contents function code to capture page information php file_get_contents function proxy obtains the code of the remote page Problems using the php file_get_contents function



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn