Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 09:32:06
Original
821 people have browsed it

ThinkPHP模板的present标签用于判断模板变量是否已经赋值

ThinkPHP模板引擎的present标签用来判断模板变量是否已经赋值,其功能相当于PHP中的isset()函数行为,格式如下:

<present name="变量名">要输出的内容</present>
Copy after login

用法举例如下:

<present name="username">{$username} 你好!</present>
Copy after login

该例子等同于:

if(isset($username)){
  echo "$username 你好!";
}
Copy after login

此外,判断没有赋值可采用notpresent标签,用法如下:

<notpresent name="username">username不存在活未登录</notpresent>
Copy after login

还可以把上述两个标签合并为:

<present name="username">{$username} 你好!<else/>username不存在活未登录</present>
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!