ThinkPHP模板标签eq if 中区分0,null,false的方法

 

ThinkPHP模板标签eq if 中区分0,null,false的方法

条件语句,

<select name="status" lay-filter="type">

            <option value="">全部</option>

            <option value="1" {if condition="isset($param.status) and $param.status eq 1"}selected{/if}>正常</option>

            <option value="0" {if condition="isset($param.status) and $param.status heq '0'"}selected{/if}>禁用</option>

            <option value="-1" {if condition="isset($param.status) and $param.status eq -1"}selected{/if}>已删除</option>

</select>

 

会遇到这种问题 ,为空和null 和0 的情况

解决方法:

<!--heq标签-->

<heq name="var" value="0">...</heq>
<heq name="var" value="">...</heq>
<heq name="var" value="false">...</heq>

<!--if标签中使用-->

<if condition="$var heq 0">...</if>
<if condition="$var heq ''">...</if>
<if condition="$var heq false">...</if>

 

 heq 恒等于

nheq 不恒等于

 

 

文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。

 

若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)

原文地址:https://www.cnblogs.com/lovebing/p/12882225.html