thinkphp Template If label usage detailed _php instance

Source: Internet
Author: User
The If label of the thinkphp can be used to define complex condition judgments.For example:

 
  
   
   value1
  
   value2
  value3
    
   
 
  

Note: in the condition attribute can support EQ and other judgment expressions, with the above comparison label, but does not support the use of ">", "<" and other symbols, because it will confuse the template parsing , so the following usage is wrong:

 
  
   
   value1
  
    
    value2
 
  

Must be changed to:

 
  
   
   value1
  
    
    value2
 
  

In addition, we can use PHP code in the condition attribute , for example:

 
  
   
   thinkphp
  
    
    other Framework
 
  

The Condition property can support point syntax and object syntax, such as automatically determining whether a user variable is an array or an object:

 
  
   
   thinkphp
  
    
    other Framework
 
  

Or know that the user variable is an object

 
  
   
   thinkphp
  
    
    other Framework
 
  

Note: Since the condition property of the IF tag is basically PHP syntax, it is much more concise to use the judgment tag and switch label as much as possible, in principle, the switch and the comparison label can be used to resolve as far as possible without the IF tag to complete. Because switch and comparison tags can use variable adjusters and system variables. If the IF tag still does not meet the requirements under certain special requirements, you can write the code directly using native PHP code or PHP tags .

  • Related Article

    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.