Detailed introduction to the method of distinguishing 0, null and false in ThinkPHP template tag eq if

黄舟
Release: 2023-03-06 21:06:02
Original
2070 people have browsed it

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 &#39;&#39;">...</if><if condition="$var heq false">...</if>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!