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

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

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)
這是第二個模板文件喲 ,歡迎你的測試




主站蜘蛛池模板: 色综合久久久久久久 | 欧洲97色综合成人网 | 欧美亚洲精品在线 | 桃花综合久久久久久久久久网 | 日本高清视频免费在线观看 | 日日淫| 日本高清天码一区在线播放 | 青草99 | 午夜影视在线视频观看免费 | 日韩成人高清 | 亚洲性久久久影院 | 一二三四日本高清 | 中文字幕在线观看日本 | 亚洲综合站 | 一级片aaaa | 日日夜夜免费精品 | 亚洲福利一区二区三区 | 一级淫| 一本久久精品一区二区 | 色噜噜狠狠大色综合 | 天天搞夜夜操 | 欧洲vps一级视频 | 中国黄色毛片 | 日本高清视频免费在线观看 | 日韩性网 | 日本一道在线观看 | 欧美一级特黄特色大片 | 中文字幕自拍 | 日韩一区精品 | 青青青国产在线手机免费观看 | 四虎在线免费 | 性生活一区 | 亚洲免费观看 | 日本mv精品中文字幕 | 天堂8中文在线bt | 四虎国产精品永久地址51 | 亚洲国产成人久久一区久久 | 天天躁夜夜躁狠狠躁2021 | 亚洲 欧美 清纯 丝袜 另类 | 青娱乐欧美 | 青青干视频 |