PHP page static example sharing

小云云
Release: 2023-03-19 22:38:02
Original
1368 people have browsed it

Page staticization, as the name suggests, is to convert dynamic PHP into static Html. This article mainly explains the principles and related methods of PHP page staticization through examples. Friends in need can refer to it. Hope it helps everyone.

The process is as shown below

The user accesses index.php. If index.html exists and is within the validity period, index.html will be output directly, otherwise it will be generated. index.html

file_put_contents()Output static file

ob_start()Open PHP buffer

ob_get_contents()Get buffer content

ob_clean() clears the buffer

ob_get_clean() is equivalent to ob_get_contents()+ob_clean()

Code example


select('user', ['uid', 'username', 'email']); // 引入模板 require_once "./templates/index.php"; // 写入html file_put_contents('./html/index.html', ob_get_contents()); }
Copy after login

Related recommendations:

PHP page static implementation code

ThinkPHP3.2.3 Page static implementation method

htmlCase of implementing page static


The above is the detailed content of PHP page static example sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!