Detailed explanation of ThinkPHP template judgment output Empty tag usage
- 2021-07-06 10:28:50
- OfStack
The empty tag of the ThinkPHP template is used to determine whether the template variable is null.
The ThinkPHP template empty tag is used to determine whether the template variable is null, and its function is equivalent to the empty () function behavior in PHP. empty tags use the following format:
<empty name=" Variable name "> What to Output </empty>
The specific usage is shown in the following example:
<empty name="username">username Is a null value </empty
This example is equivalent to:
<?php
if(empty($username)){
echo 'username Is a null value ';
}
?>
If a non-null value is determined, the notempty tag can be used, as follows:
<notempty name="username">username Not empty </notempty>
The two labels can be combined to write:
<empty name="username">username Is a null value <else/>username Not empty </empty>