六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

cqlctpl php模板開始提供,最好用,技巧最強大的模板

[摘要]這個是比較好用的模板,比Smarty,FastTemplate and PHPLIB Template都好用中文文檔案 http://www.cqlc.net/cn_cqlctpl.txt這里是演示地址:http://www.cqlc.net/web/tml.php 請尊重作者的勞動成果,下面演示...
這個是比較好用的模板,比Smarty,FastTemplate and PHPLIB Template都好用

中文文檔案 http://www.cqlc.net/cn_cqlctpl.txt

這里是演示地址:http://www.cqlc.net/web/tml.php

請尊重作者的勞動成果,下面演示的3個文件下載地址:http://www.cqlc.net/cqlctpl.zip

我的主頁是:http://www.cqlc.net

1 標簽:

(1),變量:{$key} 可以是一般變量,數組和類的成員,但字符不能用 " ,只能是單引號 '

例子: {$value} ,{$a[0]} ,{$this->a['color']} 這樣寫是錯的{$this->["color"]}

(2),循環:{loop:循環語句}其他代碼{/loop} 支持for和while循環

例子: {loop:for($i=10;$i<=20;$i++)} test {$i} {/loop} 輸出(test)20~30的數
{loop:while($i++<10)} test {$a[$i]} {/loop} 輸出(test)20~30的數組

(3),邏輯:{logi:條件語句}其他代碼{/logi} 支持if,elseif,else

例子: {logi:if($i==1)} test {$i} {/logi}
{logi:elseif($i==2)} test {$a[$i]} {/logi}
{logi:else} test {$a[$i]} {/logi}

(4),程序:{exec:語句} 程序段,可以是函數,注意字符只能用 ',不能用"
例子 : {exec:$a='hello'.$i} 正確 {exec:$a="hello$i"}錯誤
{exec:echo $a}
{exec:echo time()}
{exec:$this->outpage(1,2,'index.php')}

(5),{* 模板注釋*} 例子:{*這里不會輸出的*}

2,模板輸出 :

只輸出:eval(cqlctpl(模板文件)) 例子:eval(cqlctpl("1.tml"))
套模板:{exec:eval(cqlctpl(模板文件))} 例子:{exec:eval(cqlctpl($Templatefile))}
{*這里是在模板中掉用其他模板文件*}

3,函數原代碼:

function cqlctpl($file) /*函數作者,cqlc,主頁:http://www.cqlc.net,
中文檔案 http://www.cqlc.net/cn_cqlctpl.txt */
{
$fp=fopen($file,"r");
$msg="echo\"".str_replace("\"","\\\"",fread($fp,filesize($file)))."\";";
fclose($fp);
$oldstr=array(0=>"/\{loop:([^\}]+)\}(.+)\{\/loop\}/si",
1=>"/\{logi:([^\}]+)\}(.+)\{\/logi\}/si",
2=>"/\{exec:([^\}]+)\}/si",
3=>"/(\{\*[^\*]+\*\})/si"
);
$newstr=array(0=>"\";\\1{echo\"\\2\";}echo\"",
1=>"\";\\1{echo\"\\2\";}echo\"",
2=>"\";\\1;echo\"",
3=>""
);
return preg_replace($oldstr,$newstr,$msg);
}
4,模板舉例:

模板文件:1.tml的原代碼

<h1> {$title} (1.tml) </h1> {*this is a title*}

{loop:for($i=0;$i<10;$i++)} {*loop start*}

<p> {$body} is {$array[$i]} {*out the msg*}

{logi:if($i>5)} <p> {$i} is biger than 5 {*logic start*}

{/logi} {*login end*}

{/loop} {*loop end*}

{exec:$time=time()} {*exec start and end*}

{exec:echo '<p>time is '.$time} {*exec start and end*}

{exec:eval(cqlctpl('2.tml'))} {*this is include other tml*}

模板文件:2.tml的原代碼
<P> <h1>this is other tml(2.tml)</h1>
{ exec:test()}

演示的php腳本
tml.php:
<?
function cqlctpl($file) /*函數作者,cqlc,主頁:http://www.cqlc.net,
中文文檔案 http://www.cqlc.net/cn_cqlctpl.txt */
{
$fp=fopen($file,"r");
$msg="echo\"".str_replace("\"","\\\"",fread($fp,filesize($file)))."\";";
fclose($fp);
$oldstr=array(0=>"/\{loop:([^\}]+)\}(.+)\{\/loop\}/si",
1=>"/\{logi:([^\}]+)\}(.+)\{\/logi\}/si",
2=>"/\{exec:([^\}]+)\}/si",
3=>"/(\{\*[^\*]+\*\})/si"
);
$newstr=array(0=>"\";\\1{echo\"\\2\";}echo\"",
1=>"\";\\1{echo\"\\2\";}echo\"",
2=>"\";\\1;echo\"",
3=>""
);
return preg_replace($oldstr,$newstr,$msg);
}

function test(){echo"<p>這是第二個模板文件喲 ,歡迎你的測試";} /*定義一個函數*/

$title="這是第一個模板文件";

$body="這里已經開始輸出了 ";

for($i=0;$i<10;$i++)$array[$i]="hello world $i";

eval(cqlctpl("1.tml"));


5,模板輸出結果,見演示:http://www.cqlc.net/web/tml.php


這是第一個模板文件 (1.tml)
這里已經開始輸出了 is hello world 0

這里已經開始輸出了 is hello world 1

這里已經開始輸出了 is hello world 2

這里已經開始輸出了 is hello world 3

這里已經開始輸出了 is hello world 4

這里已經開始輸出了 is hello world 5

這里已經開始輸出了 is hello world 6

6 is biger than 5

這里已經開始輸出了 is hello world 7

7 is biger than 5

這里已經開始輸出了 is hello world 8

8 is biger than 5

這里已經開始輸出了 is hello world 9

9 is biger than 5

time is 1059227729


this is other tml(2.tml)
這是第二個模板文件喲 ,歡迎你的測試




主站蜘蛛池模板: 亚洲精品视频在线观看你懂的 | 天天干天天操天天射 | 伊人亚洲综合网 | 青春草国产成人精品久久 | 日韩欧美伊人久久大香线蕉 | 探花2700视频 | 手机看片91 | 日韩成人免费aa在线看 | 亚洲 自拍 中文字幕 在线 | 色噜噜视频在线观看 | 午夜影院亚洲 | 三级香蕉| 欧美性猛交xxxx乱大交蜜桃 | 色播欧美 | 亚洲精品国产福利片 | 三级理论 | 色先锋资源 | 亚洲丁香婷婷综合久久六月 | 亚洲国产成人va在线观看网址 | 我要看一级黄色 | 日本高清无卡码一区二区久久 | 四虎8848永久在线 | 日韩美女在线观看 | 日韩乱码中文字幕视频 | 亚洲婷婷六月 | 伊人影视在线观看日韩区 | 一二三四影视大全免费观看电视剧 | 色天使视频 | 午夜久久久久久网站 | 手机看片欧美日韩 | 青娱极品盛宴国产精品分类 | 在线亚州 | 日韩精品资源 | 综合色在线观看 | 人人模人人看 | 永久看一二三四线 | 亚洲高清视频一区 | 天天插日日插 | 日韩综合久久 | 青青青视频免费观看 | 天天射天天干天天插 |