Content to output"."/> Content to output".">
Home > Article > PHP Framework > How to determine whether a variable is empty in thinkphp5
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 "fac2daa36aeb688e55bc0c64111563bcContent to be outputb9068ac49ba4bb88208133fa713e1c95".
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!