ThinkPHP template comparison label usage details _ PHP Tutorial

Source: Internet
Author: User
The usage of the ThinkPHP template comparison label is described in detail. The ThinkPHP template engine provides a wide range of comparison labels. the usage format is as follows: compare the value content of the variable value of the tag name. the comparison tag supported by the tag ThinkPHP system and the template engine of ThinkPHP provide a wide range of comparison tags. the usage format is as follows:

 <比较标签 name="变量" value="值">
  
Content
 

The comparison labels supported by ThinkPHP and their meanings are as follows:

Eq or equal: equal
Neq or notequal: not equal
Gt: greater
Egt: greater than or equal
Lt: less
Elt: less than or equal
Heq: constant equals
Nheq: non-constant equals

1. the usage of comparison labels is basically the same. The difference is that the judgment conditions are different..

For example, eq labels:

 
  value
 

Indicates that the value of the name variable is equal to the value and is output.

Or you can write it as follows:

 
  value
 

It can also be used in combination with else labels.Such:

 
  
Equal
  Not Equal
 

The gt label is as follows:

 
  value
 

Indicates output when the value of the name variable is greater than 5.

The egt label is as follows:

 
  value
 

Indicates output when the value of the name variable is no less than 5

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:

 
  {$vo.name}
 

Indicates that when the vo object attribute (or array, or automatic judgment) is 5, the output is

 
  {$vo.name}
 

Indicates that when the vo object property is equal to 5, the output is

 
  {$vo.name}
 

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


3. you can also use functions for variables.

For example:

 
  {$vo.name}
 

Indicates that when the string length of the vo object's attribute value is equal to 5, the output is

4. variable names support system variables.For example:

 
  
Equal
  Not Equal
 

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

For example:

 
  {$vo.name}
 

It indicates that when the vo object property is equal to $ a, the output is

6. all comparison labels can use the compare label.(In fact, all the comparison labels are the alias of the compare label), for example:

 
  value
 

Indicates the output when the value of the name variable is equal to 5.

Equivalent

 
  value
 

The value of the type attribute is the name of the comparison label listed above.

Comparison label name = "variable" value = "value" content/comparison label the comparison label supported by ThinkPHP and its representation...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.