Thinkphp的<in>、<notin>和<range>标签的使用和异同
2017-05-16 08:31
621 查看
ThinkPHP的in标签用于某个模板变量是否在某个范围之内,如果是,则输出内容,如果不是,就不输出内容。(可用于多用户权限分配)
语法:
<in name="变量名" value="值1,值2,...">要输出的内容</in>
使用时,在模块操作(如 Index/Index )里设定变量并赋值给模板:
在前台模板中,使用<in>标签用法如下:
<in name="groupId" value="1,2,3">显示内容</in>
运行可输出:
显示内容
若是在前台模板中:
<in name="groupId" value="a,b,c">显示内容</in>
运行则不输出任何内容。
与<in>标签对应的还有个<notin>标签,即判断不在某个范围内:
语法:
<in>标签和<notin>标签合起来用就是:
可以达到同样效果的还有<range>标签,<in>和<notin>标签也可以使用<range>标签来替代:
语法:
这个例子相当于<in>标签,当type属性的值为"notin"时就相当于<notin>标签。
语法:
<in name="变量名" value="值1,值2,...">要输出的内容</in>
使用时,在模块操作(如 Index/Index )里设定变量并赋值给模板:
$groupId = 1; $this->assign( "groupId", $groupId );
在前台模板中,使用<in>标签用法如下:
<in name="groupId" value="1,2,3">显示内容</in>
运行可输出:
显示内容
若是在前台模板中:
<in name="groupId" value="a,b,c">显示内容</in>
运行则不输出任何内容。
与<in>标签对应的还有个<notin>标签,即判断不在某个范围内:
语法:
<notin name="groupId" value="1,2,3">不显示内容</notin>
<in>标签和<notin>标签合起来用就是:
<in name="groupId" value="1,2,3">显示内容<else />不显示内容</in>
可以达到同样效果的还有<range>标签,<in>和<notin>标签也可以使用<range>标签来替代:
语法:
<range name="groupId" value="1,2,3" type="in" >显示内容</range>
这个例子相当于<in>标签,当type属性的值为"notin"时就相当于<notin>标签。
相关文章推荐
- <s:iterator>标签内使用<s:if>判断条件
- <html:select>,<html:option>,<html:options>,<html:optionsCollection>标签使用
- <html:select>,<html:option>,<html:options>,<html:optionsCollection>标签使用
- <转> 解决异常:IllegalStateException: Fragment <ThisFragment> is not currently in the FragmentManager
- <fieldset>和<legend>标签的使用
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方 在Spring MVC中的配置中一般会遇到这两个标签,作为<
- Mybatis的<where><trim><set>标签使用和排重
- <<Think in Java 4 >>中关于使用XOM操作xml文件
- MyBatis中<resultMap>的<association>和<collection>标签的使用
- springMVC 注解标签 结合 <context:component-scan>使用的功能等效于 <bean id="XXX" class="XXX">
- <s:if></s:if>标签使用
- Python使用eval强制转换字符串为字典时报错:File "<string>", line 1, in <module> NameError: name 'nan' is not defined
- "<>"、"!="、"not in"、"exsits"和"not exists"的使用规范
- <html:select>,<html:option>,<html:optionsCollection>标签使用
- thinkphp模板中标签<volist>,<if>和 U函数的使用
- Mybatis的mapper.xml的传值和<if></if>标签的使用(学习分享)
- HTML <object>与<param> 标签的使用
- 为什么Thinkphp 中的<if><volist>等标签不能用
- HTML <frameset> 标签的使用
- 学习:New in SharePoint 2010 CAML Query <IN>,<INCLUDES> &< NOT INCLUDES>(转)