The following editor will bring you a ThinkPHPtemplate tageq if method to distinguish between 0, null and false. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.
When I was working on the project, I found that in ThinkPHP’s template tag eq, the judgments for 0, null, and false are the same, that is to say, if the variable has these three values I couldn't tell the difference, which made me very depressed. I looked through the official manual and couldn't find it. I thought it shouldn't be, so I looked through it again and found that there are heq and nheq labels. The official manual only mentioned it, but it didn't. To elaborate, many people may have overlooked that this label is used to determine equality, which is equal to "===". Now, the problem is solved. The specific usage method is the same as the eq tag,
as follows:
<!--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>
The above is the detailed content of Detailed introduction to the method of distinguishing 0, null and false in ThinkPHP template tag eq if. For more information, please follow other related articles on the PHP Chinese website!