Home > Backend Development > PHP Tutorial > ThinkPHP template judgment output Present tag usage detailed explanation_PHP tutorial

ThinkPHP template judgment output Present tag usage detailed explanation_PHP tutorial

WBOY
Release: 2016-07-13 10:26:18
Original
1120 people have browsed it

The present tag of ThinkPHP template is used to determine whether the template variable has been assigned a value .

The present tag of ThinkPHP template engine is used to determine whether the template variable has been assigned a value. Its function is equivalent to the isset() function behavior in PHP , and the format is as follows:

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

Usage examples are as follows:

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

This example is equivalent to:

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

In addition, the notpresent tag can be used to judge that there is no assignment. The usage is as follows:

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

You can also combine the above two tags into:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824721.htmlTechArticleThe present tag of ThinkPHP template is used to determine whether the template variable has been assigned a value. The present tag of ThinkPHP template engine is used to determine whether the template variable has been assigned a value. Its function is equivalent to PH...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template