Home Backend Development PHP Tutorial Detailed explanation of the usage of ThinkPHP template comparison tag_PHP tutorial

Detailed explanation of the usage of ThinkPHP template comparison tag_PHP tutorial

Jul 13, 2016 am 10:26 AM
thinkphp Label template

ThinkPHP template engine provides a wealth of comparison tags, and their usage format is:

<比较标签 name="变量" value="值">内容</比较标签>
Copy after login

The comparison tags supported by the ThinkPHP system and their meanings are:

eq or equal: equal to
neq or notequal: not equal to
gt: greater than
egt: greater than or equal to
lt: less than
elt: less than or equal to
heq: constant equal to
nheq: not always equal to

1. The usage of comparison tags is basically the same, the difference lies in the different conditions for judgment .

Such as eq tag:

<eq name="name" value="value">value</eq>
Copy after login

means that if the value of the name variable is equal to value, it will be output.

Or it can also be written as:

<equal name="name" value="value">value</equal>
Copy after login

can also be mixed with else tags , such as:

<eq name="name" value="value">相等<else/>不相等</eq>
Copy after login
The

gt tag is used as follows:

<gt name="name" value="5">value</gt>
Copy after login

means that when the value of the name variable is greater than 5, output

The

egt tag is used as follows:

<egt name="name" value="5">value</egt>
Copy after login

means that when the value of the name variable is not less than 5, output

2. The variables in the comparison tag can support object attributes or arrays, or even system variables :

An example of the eq tag is as follows:

<eq name="vo.name" value="5">{$vo.name}</eq>
Copy after login

means that when the attribute of the vo object (or array, or automatic judgment) is equal to 5, output

<eq name="vo:name" value="5">{$vo.name}</eq>
Copy after login

means that when the attribute of the vo object is equal to 5, it will output

<eq name="vo['name']" value="5">{$vo.name}</eq>
Copy after login

means that when $vo['name'] is equal to 5, output


3. You can also use functions for variables

For example:

<eq name="vo:name|strlen" value="5">{$vo.name}</eq>
Copy after login

means that when the string length of the attribute value of the vo object is equal to 5,

will be output

4. Variable names can support system variables , for example:

<eq name="Think.get.name" value="value">相等<else/>不相等</eq>
Copy after login

5. Usually the value of the comparison tag is a string or number. If you need to use a variable, you only need to add the "$" sign in front.

For example:

<eq name="vo:name" value="$a">{$vo.name}</eq>
Copy after login

means that when the attribute of the vo object is equal to $a, it will output

6. All comparison tags can use the compare tag (in fact, all comparison tags are aliases of the compare tag), for example:

<compare name="name" value="5" type="eq">value</compare>
Copy after login

means that when the value of the name variable is equal to 5, output

is equivalent to

<eq name="name" value="5" >value</eq>
Copy after login

The value of the type attribute is the comparison tag name listed above

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824723.htmlTechArticleThinkPHP template engine provides a wealth of comparison tags, and its usage format is: comparison tag name="variable" value= "Value" content/comparison tag The comparison tags supported by the ThinkPHP system and what they represent...
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

How to search for text across all tabs in Chrome and Edge How to search for text across all tabs in Chrome and Edge Feb 19, 2024 am 11:30 AM

How to search for text across all tabs in Chrome and Edge

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Which one is better, laravel or thinkphp?

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

How to add PPT mask

How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to? How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to? Mar 22, 2024 am 10:28 AM

How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to?

See all articles