ThinkPHP template IF tag usage details _ PHP Tutorial

Source: Internet
Author: User
ThinkPHP template IF label usage details. The IF tag of ThinkPHP can be used to define complex condition judgments, for example, ifcondition ($ nameeq1) OR ($ namegt100) value1elseifcondition $ nameeq2value2elsevalue3if note ThinkPHP IF Tag can Used to define complex condition judgmentsFor example:

 
   value1
  value2
   value3
 

Note: The condition attribute supports eq and other judgment expressions. comparison labels are the same as above, but they do not support the use of symbols such as ">" and "<", because template parsing is obfuscated, so the following usage is incorrect:

 
   value1
   value2
 

Must be changed:

 
   value1
   value2
 

In addition, wePhp code can be used in the condition attributeFor example:

 
   ThinkPHP
   other Framework
 

The condition attribute supports dot syntax and object syntax, for example, automatically determining whether the user variable is an array or an object:

 
   ThinkPHP
   other Framework
 

Or you know that the user variable is an object.

 
   ThinkPHP
   other Framework
 

Note:Because the condition attribute of the if tag basically uses the php syntax, it is more concise to use the judgment tag and Switch tag. in principle, if you can use the switch or comparison label, try not to use the if label. Because switch and comparison labels can use variable regulators and system variables. IF the IF tag still cannot meet the requirements under some special requirements, you can use native php code or PHP label to directly write the code..

Condition is used to define complex condition judgments, such as: if condition = "($ name eq 1) OR ($ name gt 100) "value1elseif condition =" $ name eq 2 "/value2else/value3/if note...

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.