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

WBOY
Release: 2016-07-13 10:26:17
Original
1045 people have browsed it

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