找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 563|回复: 0
打印 上一主题 下一主题

Pain 全世界最小最简单的PHP模板引擎 (普通版)

[复制链接]

2487

主题

2487

帖子

7391

积分

论坛元老

Rank: 8Rank: 8

积分
7391
跳转到指定楼层
楼主
发表于 2018-2-14 08:32:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

            打包下载
Pain.php
[U]复制代码[/U] 代码如下:
var[$variable]=$value;
}
public function display($template_name,$return_string=false)
{
//first find whether the tmp file in tmp dir exists.
if(file_exists("tmp/temp_file.php"))
{
unlink("tmp/temp_file.php");
}
extract($this->var);
$tpl_content=file_get_contents($template_name);
$tpl_content=str_replace("{@", "", $tpl_content);
//create a file in the /tmp dir and put the $tpl_contentn into it, then
//use 'include' method to load it!
$tmp_file_name="temp_file.php";
//$tmp is the handler
$tmp=fopen("tmp/".$tmp_file_name, "w");
fwrite($tmp, $tpl_content);
include "tmp/".$tmp_file_name;
}
}
?>

test.php
[U]复制代码[/U] 代码如下:
assign("songyu",$songyu);
$pain->assign("zhangyuan",$zhangyuan);
$pain->display("new_file.html");
?>

new_file.html
[U]复制代码[/U] 代码如下:




new_file


{@$songyu@}

{@$zhangyuan@}


            
            
您可能感兴趣的文章:
  • 需要使用php模板的朋友必看的很多个顶级PHP模板引擎比较分析
  • PHP中MVC模式的模板引擎开发经验分享
  • PHP原生模板引擎 最简单的模板引擎
  • CodeIgniter使用phpcms模板引擎
  • php smarty模板引擎的6个小技巧
  • php模板引擎技术简单实现
  • 自定义min版smarty模板引擎MinSmarty.class.php文件及用法
  • 简单的自定义php模板引擎
  • PHP的自定义模板引擎
  • PHP实现简单的模板引擎功能示例
            
  • 分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    用户反馈
    客户端