This article explains the difference and comparison between if and eq in Thinkphp template tags through examples. Share it with everyone for your reference. The specific analysis is as follows:
In TP template language. Both if and eq can be used to compare variables. To summarize the following points:
1. Comparison of two variables:
<if condition="$item.group_id eq $one.group_id"> <eq name="item.group_id" value="$one.group_id">
The former's IF will fail the judgment, but the latter's
2. When the value is NULL:
<if condition="name neq 'NULL'">just a test</if> <neq name="name" velue="">just a test</neq>
The former's IF fails to judge, and the latter's
3. When the multi-dimensional array and the subscript is 0:
<if condition="name.0 neq 'test'">just a test</if> <eq name="name.0″ velue="test">just a test</eq>
The former cannot be compiled at all using IF, but it can be done by using the following eq
I hope this article will be helpful to everyone’s PHP programming based on ThinkPHP.