Home > Database > Mysql Tutorial > Example of the simplest way to generate static HTML pages in php

Example of the simplest way to generate static HTML pages in php

怪我咯
Release: 2017-07-11 16:13:14
Original
2765 people have browsed it

Nowadays, many website systems, such as dedecms, phpcms, empire and other well-known content management systems, provide the function of generating static pages, which is not only beneficial to search engine crawling, but also effectively reduces server pressure. For friends who are learning PHP and will be engaged in WEB website development, it is necessary to understand this function. This article mainly introduces an example of the simplest way to generate staticHTML pages in PHP. This article uses template replacement. Generating HTML pages is the most common method. Friends who need it can refer to

PHP file name: dome.php

The code is as follows:

<?php
    $string = 1;
    ob_start();
    @readfile("templets/list.html");
    $text = ob_get_flush();
    $myfile = fopen("list.html","w");
    $text = str_replace ("{counent}",$string,$text);
    fwrite($myfile,$text);
    ob_clean();
    ?>
Copy after login

Template file Name: templets/list.html

The code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
<table width="500" border="0" cellpadding="5" cellspacing="1" align="center" bgcolor="#add3ef">
  <tr bgcolor="#eff3ff">
    <td>用户:{counent_user}  标题:{counent_title}  发布时间:{counent_lastdate}</td>
  </tr>
  <tr bgcolor="#fff">
    <td>内容:{counent_content}</td>
  </tr>
</table>
</form>
</html>
Copy after login

The above is the detailed content of Example of the simplest way to generate static HTML pages in php. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template