PHP讀寫文件的方法(生成HTML)
更新時間:2006年11月27日 00:00:00 作者:
<?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);
?>
file_get_contents -- 將整個文件讀入一個字符串
file -- 把整個文件讀入一個數(shù)組中
//生成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);
?>
file_get_contents -- 將整個文件讀入一個字符串
file -- 把整個文件讀入一個數(shù)組中
您可能感興趣的文章:
相關文章
創(chuàng)造世界上最簡單的 PHP 開發(fā)模式
這篇文章主要介紹了創(chuàng)造世界上最簡單的 PHP 開發(fā)模式2006-12-12