Home > Backend Development > PHP Tutorial > How to read and write files to generate HTML with PHP

How to read and write files to generate HTML with PHP

怪我咯
Release: 2023-03-12 19:08:02
Original
2816 people have browsed it

<?php  
//生成HTML  
$countfile="template.html";  
$num=file_get_contents($countfile);  
echo $num;  
$num=str_replace("|*|*|PAGE_TITLE|*|*|","myhome",$num);  
$path="template.html";  
$handle=fopen($path,"w"); //写入方式打开新闻路径  
fwrite($handle,$num); //把刚才替换的内容写进生成的HTML文件  
fclose($handle);  
?>
Copy after login

file_get_contents -- Read the entire file into a string
file -- Read the entire file into an array

The above is the detailed content of How to read and write files to generate HTML with 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