AmMrWu

a fish.

导航

php中模版生成html的原理

//打开模版文件
$file=fopen('temp.html','r');
$html_content=fread($file,filesize('temp.html'));
//替换模版标签
$php_content=str_replace('{','<?php echo ',$html_content);
$php_content=str_replace('}',';?>',$php_content);
//新建php模版文件
$php_temp=fopen('temp.php','w');
fwrite($php_temp,$php_content);
//赋值
$title='temp';
$content='temp';
include('temp.php');

posted on 2012-08-31 17:43  RorySmart  阅读(343)  评论(0编辑  收藏  举报