thinkphp的present模版输出
+-------------------------------------------------------------------------------------+
thinkphp的模版输出之present标签的使用:
present标签:
present标签用来判断模版变量是否是已经赋值,相当于php的isset()函数行为:
<present name="变量名">要输出的内容</present>
例子:
<present name="username">{$username},你好!</present>
该例子相当于:
if(isset($username)){
echo "$username 你好";
}
notpresent标签:
对应的还有个notpresent标签,为present标签的反义.(即!isset())
<notpresent name="username">username 变量还是没有赋值</notpresent>
两个标签合并起来等于
<present name="username">username变量已经赋值<else/>username变量还没有赋值</present>
The boy who love php and Python!