PHP static HTML_PHP tutorial

Source: Internet
Author: User
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 ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.