Home >Backend Development >PHP Tutorial >Generate .Shtml PHP read and write file method to generate HTML

Generate .Shtml PHP read and write file method to generate HTML

WBOY
WBOYOriginal
2016-07-29 08:35:211256browse

//Generate HTML
$countfile="template.html";
$num=file_get_contents($countfile);
echo $num;
$num=str_replace("|*|*|PAGE_TITLE|*| *|","myhome",$num);
$path="template.html";
$handle=fopen($path,"w"); //Open the news path in writing mode
fwrite($handle, $num); //Write the replaced content into the generated HTML file
fclose($handle);
?>
file_get_contents -- Read the entire file into a string
file -- Read the entire file into a string in array

The above introduces the method of generating .Shtml PHP read and write files to generate HTML, including the content of generating .Shtml. I hope it will be helpful to friends who are interested in PHP tutorials.

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