首頁  >  文章  >  後端開發  >  Pain 全世界最小最簡單的PHP模板引擎 普通版

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

WBOY
WBOY原創
2016-07-29 08:47:01956瀏覽

壓縮下載
Pain.php

複製程式碼 程式碼如下:


class Pain
{
public $var=array(php); y/~m/id是給模板賦值var的方法
public function allocate($variable,$value=null)
{
$this->var[$variable]=$value;
}
public function display($template_name,$return_string_name,$return_string_name,$return_string_name,$return_str. )
{
//先判斷tmp目錄下的tmp檔案是否存在。
if(file_exists("tmp/temp_file.php"))
{
unlink("tmp/temp_file.php");
}
extract($this->var);
$tpl_c
extract($this->var);
$tpl_c e? echo ", $tpl_content);
$tpl_c " ?>", $tpl_content);
//在/tmp目錄下建立一個文件,並將$tpl_contentn放入其中,然後
//使用'include'方法載入它!
$tmp_file_name="temp_file.php";
//$tmp 是處理程序
$tmp=fopen("tmp/".$tmp_file_name, "w");
fwrite($tmp, $tpl_content);
include " tmp/".$tmp_file_name;
}
}
? >

test.php

複製程式碼 程式碼如下:

require_once "Pain.php";
require_once "Pain.php";
require_once "Pain.php"; 程式碼如下:

BR>"http://www.w3.org/TR/ html4/strict.dtd">
"http://www.w3.org/TR/ html4/strict.dtd">

;
/>
new_file 標題>
頭>
;
{@$songyu@}
>
{@$zhangyuan@}

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn