powerpoint 範本 默默簡單的寫了一個範本引擎
引擎檔案
複製程式碼 程式碼如下:
/**
* 默默基於Discuz的模板引擎開發的OOP類模板引擎,可支援模板快取並產生hash的md5值。由hash值来判断模板是否被修改,假如被修改则重新生成缓存文件,假如没有被修改,则直接调用缓存文件.
* 版本:1.0.0.1 beta 测试版
*/
class mmtp{
var $left_tags="{";
var $right_tags="}";
var $tp_suffix=".html";
var $cache_suffix=".tpl";
var $tp_dir="./";
var $cache_dir="./";
/**
* 允许循环嵌套的次数,默认为5
*
* @var unknown_type
*/
var $nest = 5;
/**
* 模板路径
*
* @param unknown_type $tp_dir
* @return mmtp
*/
function __setdir($tp_dir){
if(file_exists($tp_dir)){
$this->tp_dir=$tp_dir;
}else{
$this->error("模板路径不存在");
}
}
/**
* 设置缓存目录
*
* @param unknown_type $cache_dir
*/
function __setcdir($cache_dir){
if(file_exists($cache_dir)){
$this->cache_dir=$cache_dir;
}else{
$this->error("缓存路径不存在");
}
}
/**
* 输出错误信息
*
* @param unknown_type $msg
*/
function error($msg){
print "
}
/**
* 解析範本
*
*/
/***/
/***/
$tp_path=$this->tp_dir.$file.$this->tp_suff九;
$fp=fopen($tp_path,"rb"); $fp=fopen($tp_path,"rb"); $fp=fopen($tp_path,"rb"); $fp=fopen($tp_path,"rb"); $fp=fopen($tp_path,"rb"); $fp=fopen($tp_path,"rb"); atch_hash($file)) {
$template=$this->file_read($tp_path); $const_regexp = "([a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*
$template = preg_replace("/([nr]+)t+\stemp.
$template = preg_replace("//s")
$template = preg_replace("/{langs+(.+?)}/ies",late = preg_replace("/{langs+(.+?)}/ies",
$以 = str_replace("{LF}",
$template = preg_replace("/{(\$[a-zA-Z0-9_[]'"$.71範本);
$template = preg_replace("/$var_reglate/temps", $template = preg_replace("/$var_reglate/tempes", "$this>( preg_replace( "/==$var_regexp?>?>/es", "$this->addquote('=\1?>')", $模板); $template = preg_replace(" /[nrt]*{templates+([a-z0-9_]+)}[nrt]*/is", "n include('".$this->cache_dir."\1".$this-> cache_suffix."'); ?>n", $template);
ude ('".$this->cache_dir."\1".$$this->cache_suffix."'); ?>n ", $template);
評估+(.+?)}[nrt]*/ies", "$this->stripvtags('n\1 ?>n','')", $template);
echos+(.+?)}[nrt]*/ies", "$this->stripvtags('n echo \1; ?>n','')", $template);
preg_replace("/[nrt]*{elseifs+(.+?)}[nrt]*/ies", "$this->stripvtags('n } elseif(\1) { ?> n','') ", $template);
以$template = preg_replace
for($i = 0; $i nest; $i++) {
+)}[nr]*(. +?)[nr]*{/loop}[nrt]*/ies", "$this->stripvtags('n if(is_array(\1)) { foreach (\1 as \2) { ?> ','n\3n } } ?>n')", $template);
nrt]*(.+?)[nrt]*{/loop}[nrt]*/ies", "$this->stripvtags('n if( is_array(\1)) { foreach(\1 as \ 2 => \3) { ?>','n\4n } } ?>n')", $template);
.+? )}[nr]*(.+?)[nr]*{ /if}[nrt]*/ies", "$this->stripvtags('n if(\1) { ?>','n\2n} ?>n')", $範本);
$template = preg_replace("/{$const_regexp}/s", "=\1?>", $template);
$1. $hash=$ this->file_hash($tp_path);
$head $foot_time="";
time );
/**
* 檢查檔案是否存在且有讀取權限
*
*/
if(!file_exists($path) || !fopen($path,$method)) {
$this->error("範本 return false;
}
🎜 > function file_read($path,$length=0){
$fp=@fopen($path,"r+") ;
if($length==0){
}else{
}
fclose($fp);
🎜> }
} function file_write($path,$puts){
w+")){
$fp=@fopen($path,"w+");
🎜> fclose($fp);
> }
/**
* 計算檔案的hash
*
* @return unknown
*/
return md5_file($path);
}
/** 🎜> $read_hash=this->file_read($this->cache_ dir.$檔案.$ this ->cache_suffix,46);
$html_hash=$this->file_hash($this->tp_dir.$file.$this->tp_suffix);
if(preg_match("/".$html return true;
}
} }
函數 transamp($str) {
$str = str_replace('&', '&', $str);
$str = str_replace('"', '"', $str);
return $str;
}
函式 stripvtags($expr, $statement) {
$$> /s","\1",$expr));
$statement = str_replace("\"", """, $statement);
return $expr.$statement;
}
}
$tp=new mmtp();
$tp->__setdir("./");
$tp->__setcdir("./cache/");
$tp->tp("index1");
$_GET[it]=sdhkadajksdhajdhkajsdhjkasdjkasdhasjdhkjsadhk;
$name=2;
$head="歡迎使用MoMo模板引擎";
include("./cache/index1.tpl");
? >
範本index1.html
複製程式碼
程式碼如下:
{template index}
{if 1}
好
{else} 謝謝
{/if}
這個模板是今天下午默默寫的,你寫的比較倉促,也許有漏洞,這個版本只是存在測試版,以後我會逐步完善,先發布來,並前去瞻仰。
以上就介紹了powerpoint模板默默簡單的寫了一個模板引擎,包括powerpoint模板方面的內容,希望對PHP教程有興趣的朋友有所幫助。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

JWT是一種基於JSON的開放標準,用於在各方之間安全地傳輸信息,主要用於身份驗證和信息交換。 1.JWT由Header、Payload和Signature三部分組成。 2.JWT的工作原理包括生成JWT、驗證JWT和解析Payload三個步驟。 3.在PHP中使用JWT進行身份驗證時,可以生成和驗證JWT,並在高級用法中包含用戶角色和權限信息。 4.常見錯誤包括簽名驗證失敗、令牌過期和Payload過大,調試技巧包括使用調試工具和日誌記錄。 5.性能優化和最佳實踐包括使用合適的簽名算法、合理設置有效期、

會話劫持可以通過以下步驟實現:1.獲取會話ID,2.使用會話ID,3.保持會話活躍。在PHP中防範會話劫持的方法包括:1.使用session_regenerate_id()函數重新生成會話ID,2.通過數據庫存儲會話數據,3.確保所有會話數據通過HTTPS傳輸。

SOLID原則在PHP開發中的應用包括:1.單一職責原則(SRP):每個類只負責一個功能。 2.開閉原則(OCP):通過擴展而非修改實現變化。 3.里氏替換原則(LSP):子類可替換基類而不影響程序正確性。 4.接口隔離原則(ISP):使用細粒度接口避免依賴不使用的方法。 5.依賴倒置原則(DIP):高低層次模塊都依賴於抽象,通過依賴注入實現。

在PHPStorm中如何進行CLI模式的調試?在使用PHPStorm進行開發時,有時我們需要在命令行界面(CLI)模式下調試PHP�...

如何在系統重啟後自動設置unixsocket的權限每次系統重啟後,我們都需要執行以下命令來修改unixsocket的權限:sudo...

靜態綁定(static::)在PHP中實現晚期靜態綁定(LSB),允許在靜態上下文中引用調用類而非定義類。 1)解析過程在運行時進行,2)在繼承關係中向上查找調用類,3)可能帶來性能開銷。
