Home >Backend Development >PHP Tutorial >How to read and write files in PHP (generate HTML)_PHP tutorial
//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 an array