Static pages load quickly (what are static pages) and are conducive to search engine spider crawling, so many friends want to generate dynamic pages into static pages, so today I will introduce how Use php to generate static web pages.
Related recommendations: "php Getting Started Tutorial"
The idea is roughly like this:
1. Design a static page template and fill it in when needed Replace the content with some symbols or parameters (cannot be repeated with other codes), as shown below (simple diagram):
2. Use PHP to read the content in the database. Replace the symbols that need to be filled with the read content. For example, if the template is as shown above, replace with the web page title, and replace with the web page content. This can be replaced with the preg_replace function in php.
3. Save the replaced content as html or htm file. For example, it can be saved as news_1.html, so that such a static web page can be accessed in the browser.
Through the above three steps, you can use PHP to generate static pages. The above is just a simple idea. In the actual process of generating static pages, it may be more complicated. As long as you pay attention, learn more functions in PHP, and more If you think about it, there will be no problems that will stump you.
The above is the detailed content of How to generate static php website. For more information, please follow other related articles on the PHP Chinese website!