PHP static HTML. Static HTML is always better than dynamic pages that read content from databases. When space is not the first consideration, static HTML display is more suitable. Static HTML is always better than dynamic pages that read content from databases. When space is not the first consideration, static HTML display is more suitable.
PHP generates static pages. I have summarized the following two methods:
[Php]
$ Src = './index. tpl ';
$ Content = file_get_content ($ src );
$ Content = str_replace ('{title}', 'title', $ content );
// Same replacement
$ Content = str_replace (...);
$ Fp = fopen ('./index.html', 'w') or die ('Can not open file ');
Fputs ($ fp, $ content );
Fclose ($ fp );
Unset ($ fp );
Index. tpl
[Html]
{Title}
The second two methods are much simpler.
[Php]
Ob_start ();
$ Top_id = 34;
Require './index. php ';
Ob_end_clean ();
/** Www.2cto.com
* You can use $ top_id as the parameter in index. php, because this can be passed to the index. php page.
* Then write the HTML code generated in index. php. That is, HTML can be generated without replacement;
*/
Author: tomyjohn
Bytes. When space is not the first consideration, static HTML display is more suitable ....