<?php
Header (' content-type:text/html charset=utf-8 ');//Prevent the generated page from garbled
$title = "PHP dynamic generation static HTML page _ cloud Habitat Community"; Defining variables
$url = "http://www.jb51.net/";
$temp _file = "temp.html"; Temporary files, or template files
$dest _file = "dest_page.html"; The generated target page
$fp = fopen ($temp _file, "R"); Read-only open template
$str = Fread ($fp, FileSize ($temp _file));//Read the contents of the template
$str = Str_replace ("{penglig_site_title}", $title, $STR);/replace content
$str = Str_replace ("{Penglig_site_url}", $url, $STR);/replace content
Fclose ($FP);
$handle = fopen ($dest _file, "w"); Write to open files that need to be written
Fwrite ($handle, $STR); Write what you just replaced into the generated HTML file
Fclose ($handle);//Close Open file, release file pointer and associated buffer
echo "<script>alert (' generate success '); Window.location.href= '". $dest _file. "'; </script> ";
?>