Home >Backend Development >PHP Tutorial >ThinkPHP template range judgment output In tag and Range tag usage detailed explanation_PHP tutorial

ThinkPHP template range judgment output In tag and Range tag usage detailed explanation_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:26:20851browse

The in tag and range tag of ThinkPHP template are used to determine whether a template variable is within a certain range .
1.in tag
ThinkPHP’s in tag is used to determine whether a template variable is within a certain range. The format is as follows:

<in name="变量名" value="值1,值2,...">要输出的内容</in>

When used, set variables in module operations (such as Index/display) and assign values ​​to templates:

$groupId = 1;
$this->assign( "groupId", $groupId );

Template/Tpl/default/Index/display.html, use the in tag as follows:

<in name="groupId" value="1,2,3">管理群组</in>

Run this example to output:

Manage Groups

The php code for this example is equivalent to:

<&#63;php
if(in_array(($groupId), explode(',',"1,2,3"))){
  echo '管理群组';
}
&#63;>

Note: The value of a variable can also be a string or an array, and the value of the value attribute can use a variable.

2.notin tag

Corresponding to the in tag is the notin tag, which means it is judged not to be within a certain range:
Usage such as:

<notin name="groupId" value="1,2,3">非管理群组</notin>

The above two tag examples combined are equivalent to:

<in name="groupId" value="1,2,3">管理群组<else />非管理群组</in>

3.range tag

ThinkPHP’s in and notin tags can also be replaced by range tags, such as:

<range name="groupId" value="1,2,3" type="in" >管理群组</range>

The above example is equivalent to the in tag. When the value of the type attribute is notin, it is equivalent to the notin tag.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824717.htmlTechArticleThe in tag and range tag of ThinkPHP template are used to determine whether a template variable is within a certain range. 1.in tag ThinkPHP’s in tag is used to check whether a template variable is within a certain range...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn