thinkphp模板的present标签用于判断模板变量是否已经赋值。
thinkphp模板引擎的present标签用来判断模板变量是否已经赋值,其功能相当于php中的isset()函数行为,格式如下:
<present name="变量名">要输出的内容</present>
用法举例如下:
<present name="username">{$username} 你好!</present>
该例子等同于:
if(isset($username)){ echo "$username 你好!"; }
此外,判断没有赋值可采用notpresent标签,用法如下:
<notpresent name="username">username不存在活未登录</notpresent>
还可以把上述两个标签合并为:
<present name="username">{$username} 你好!<else/>username不存在活未登录</present>
如对本文有疑问, 点击进行留言回复!!
荐 「PHP」不依赖集成环境,使用Nginx手动配置Thinkphp运行环境
如何安装linux mint,和windows10组成双系统?
网友评论