Home > Backend Development > PHP Tutorial > Difference and comparative example analysis of Thinkphp template tags if and eq, thinkphpeq_PHP tutorial

Difference and comparative example analysis of Thinkphp template tags if and eq, thinkphpeq_PHP tutorial

WBOY
Release: 2016-07-13 09:48:08
Original
1061 people have browsed it

Example analysis of the difference and comparison between if and eq in Thinkphp template tags, thinkphpeq

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">

Copy after login

The former's IF will fail the judgment, but the latter's (or ) will be OK. It should be noted that there is no need to add the $ variable symbol to the name, but the $ variable symbol is required to the value.

2. When the value is NULL:

<if condition="name neq 'NULL'">just a test</if>
<neq name="name" velue="">just a test</neq>

Copy after login

The former's IF fails to judge, and the latter's (or ) can recognize null as ""

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>

Copy after login

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1024905.htmlTechArticleDifference and comparison example analysis of Thinkphp template tags if and eq, thinkphpeq This article describes the Thinkphp template tags if and eq differences and comparisons. Share it with everyone for your reference. Specific points...
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