Home >Backend Development >PHP Tutorial >ThinkPHP template judgment output Present tag usage detailed explanation_PHP tutorial
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>
Usage examples are as follows:
<present name="username">{$username} 你好!</present>
This example is equivalent to:
if(isset($username)){ echo "$username 你好!"; }
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>
You can also combine the above two tags into:
<present name="username">{$username} 你好!<else/>username不存在活未登录</present>