Home >php教程 >php手册 >ThinkPHP模板判断输出Present标签用法详解

ThinkPHP模板判断输出Present标签用法详解

WBOY
WBOYOriginal
2016-06-13 09:32:06861browse

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>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn