The in label and range label of the ThinkPHP template are usedDetermines whether a template variable is within a certain range..
1. in tag
The in tag of ThinkPHP is used to determine whether a template variable is within a certain range. The format is as follows:
<In name = "variable name" value = "value 1, value 2,..."> content to be output </in>
During use, set variables in module operations (such as Index/display) and assign values to the template:
$groupId = 1;$this->assign( "groupId", $groupId );
The template/Tpl/default/Index/display.html uses the in tag as follows:
<In name = "groupId" value = "1, 2, 3"> Manage groups </in>
Run this example and output:
Manage groups
The php code in this example is equivalent:
<? Phpif (in_array ($ groupId), explode (',', "1, 2, 3") {echo 'Manage group';}?>
Note: The value of a variable can also be a string or an array. The value attribute value can be a variable.
2. notin tag
There is also a notin tag corresponding to the in tag, that is, the judgment is not in a certain range:
Usage example:
<Notin name = "groupId" value = "1, 2, 3"> non-managed groups </notin>
The preceding two tag examples are equivalent:
<In name = "groupId" value = ", 3"> Manage groups <else/> unmanaged groups </in>
3. range label
The in and notin labels of ThinkPHP can also be replaced by the range label, for example:
<Range name = "groupId" value = "1, 2, 3" type = "in"> Manage groups </range>
The preceding example is equivalent to the in tag. When the value of the type attribute is notin, it is equivalent to the notin tag.