In thinkphp, you can use the empty tag to determine whether a variable is empty. The function of this tag is to determine whether a template variable is empty. Its function is equivalent to the empty() function in PHP, and the syntax is "< empty name="Variable name">Content to be output".
The operating environment of this article: Windows 10 system, ThinkPHP version 5, Dell G3 computer.
ThinkPHP template empty tag is used to determine whether the template variable is empty. Its function is equivalent to the empty() function behavior in PHP. The empty tag usage format is as follows:
<empty name="变量名">要输出的内容</empty>
The specific usage is as shown in the following example:
<empty name="username">username 为空值</empty>
This example is equivalent to:
<?php if(empty($username)){ echo 'username 为空值'; } ?>
If you judge a non-empty value, you can use the notempty tag, as follows Shown:
<notempty name="username">username 不为空</notempty>
The two tags can be combined to write:
<empty name="username">username 为空值<else/>username 不为空</empty>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to determine whether a variable is empty in thinkphp5. For more information, please follow other related articles on the PHP Chinese website!