php模版生成html的小例子
2022-08-03 09:57:03
145
{{single.collect_count}}

本节内容:

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模版文件 www.jbxue.com

$php_temp=fopen('temp.php','w');

fwrite($php_temp,$php_content);

//赋值

$title='temp';

$content='temp';

include('temp.php');

?>

您可能感兴趣的文章:

smarty模板中类似for循环功能的实现代码

smarty模板引擎的简单分页代码

smarty模板引擎中英文多编码字符截取出现乱码问题的解决方法

有关php mvc模式的模板引擎开发经验分享

细说php生成静态文件之模板与缓存

php模板函数的正则实现代码

thinkphp3.0 模板中函数的使用

thinkPHP的Html模板标签的使用方法

(图)php模板引擎Smarty详细介绍

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}