Pain.php 復(fù)制代碼 代碼如下: <?php class Pain { public $var=array(); public $tpl=array(); //this is the method to assign vars to the template public function assign($variable,$value=null) { $ " /> 青青久久av北条麻妃黑人,影音先锋男人在线资源,国内欧美视频一区二区

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

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

打包下載

Pain.php
復(fù)制代碼 代碼如下:
<?php
class Pain
{
public $var=array();
public $tpl=array();
//this is the method to assign vars to the template
public function assign($variable,$value=null)
{
$this->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("{@", "<?php echo ", $tpl_content);
$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
復(fù)制代碼 代碼如下:
<?php
require_once "Pain.php";
$pain=new Pain();
$songyu="songyu nb";
$zhangyuan="zhangyuan sb";
$pain->assign("songyu",$songyu);
$pain->assign("zhangyuan",$zhangyuan);
$pain->display("new_file.html");
?>

new_file.html
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>new_file</title>
</head>
<body>
{@$songyu@}<br/>
{@$zhangyuan@}
</body>
</html>

php技術(shù)Pain 全世界最小最簡單的PHP模板引擎 (普通版),轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 石渠县| 宁武县| 宿州市| 敦煌市| 绥中县| 黄大仙区| 永善县| 湛江市| 郯城县| 永登县| 敦化市| 盘山县| 收藏| 松原市| 弥勒县| 陇川县| 宁安市| 科技| 海宁市| 洛川县| 思南县| 叶城县| 濮阳县| 册亨县| 兴隆县| 鸡东县| 贵溪市| 昭觉县| 金乡县| 潼关县| 青河县| 定兴县| 藁城市| 阜城县| 麻阳| 和田县| 泉州市| 阳高县| 泽库县| 牡丹江市| 拉萨市|