|
Thinkphp模板的present標(biāo)簽用于判斷模板變量是否已經(jīng)賦值。
Thinkphp模板引擎的present標(biāo)簽用來判斷模板變量是否已經(jīng)賦值,其功能相當(dāng)于php中的isset()函數(shù)行為,格式如下:
<present name="變量名">要輸出的內(nèi)容</present>
用法舉例如下:
<present name="username">{$username} 你好!</present>
該例子等同于:
if(isset($username)){ echo "$username 你好!";}
此外,判斷沒有賦值可采用notpresent標(biāo)簽,用法如下:
<notpresent name="username">username不存在活未登錄</notpresent>
還可以把上述兩個標(biāo)簽合并為:
<present name="username">{$username} 你好!<else/>username不存在活未登錄</present>
php技術(shù):ThinkPHP模板判斷輸出Present標(biāo)簽用法詳解,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。