This article mainly describes the thinkphp template range to determine the output in the label and range label usage, the need for friends can refer to the following
The in label and range tags of the thinkphp template are used to determine whether a template variable is within a range .
1.in Label
The in tag of the thinkphp is used for a template variable within a range, using the following format:
<in name= "variable name" value= "value 1, value 2,..." > What to Output </in>
When used, set variables and assign values to the template in a module operation (such as Index/display):
$groupId = 1; $this->assign ("GroupId", $groupId);
Template/tpl/default/index/display.html, use the in tag usage as follows:
<in name= "groupId" value= ">", Manage Groups </in>
To run the example, you can output:
Manage groups
The PHP code for this example is equivalent to:
<?phpif (($groupId), explode (', ', ' In_array ')) { echo ' management group ';}? >
Note: The value of a variable can also be a string or an array, and the value of the property can use a variable.
2.notin Label
There is also a notin tag corresponding to the in tag, that is, the judgment is not within a certain range:
Usage such as:
<notin name= "groupId" value= ">", non-administrative group </notin>
The combination of the two tag examples above is equivalent to:
<in name= "groupId" value= ">", manage group <else/> Non-admin group </in>
3.range Label
thinkphp in and Notin tags can also be replaced with a range tag, such as:
<range name= "GroupId" value= "All In," type= "in" > Manage Groups </range>
The above example is equivalent to the in tag, which is equivalent to the Notin label when the value of the Type property is Notin.