& Lt ;? Phpheader (Content-type: text/html; charsetutf-8); if (! Function_exists (file_get_contents) {// if the system does not have the file_get_contents () function functionfile_get_contents ($ file) {// write f by yourself
- Header (Content-type: text/html; charset = utf-8 );
- If (! Function_exists (file_get_contents) {// if the system does not have the file_get_contents () function
- Function file_get_contents ($ file) {// write the file_get_contents () function by yourself
- $ Fp = fopen ($ file, r );
- $ Content = fread ($ fp, filesize ($ file ));
- Fclose ($ fp );
- Return $ content;
- }
- }
- $ Tmp_file = template.html; // template file
- $ Content = file_get_contents ($ tmp_file); // Obtain the template file content
- $ Title = title; // The value to be replaced by the template variable title.
- $ Text = text; // The value of the template variable text to be replaced
- $ Content = str_replace (<{title}>, $ title, $ content); // replace the template variable title
- $ Content = str_replace (<{text}>, $ text, $ content); // replace the template variable text
- // Echo $ content; // display the content of the replaced Template File
- MakeHtml(news.html, $ content); // write the generated static file to the news.html file.
- Echo to view files;
- Function MakeHtml ($ file, $ content ){
- $ Fp = fopen ($ file, w );
- Fwrite ($ fp, $ content );
- Fclose ($ fp );
- }
- ?>