ThinkPHP template Switch label usage example _ php instance

Source: Internet
Author: User
This article mainly introduces the Switch label usage of the ThinkPHP template. For more information, see the switch label in the ThinkPHP template to output different values in the template based on different situations.

The ThinkPHP template engine supports switch judgment and outputs different results based on different conditions. The format is as follows:

 
  
   
Output content 1
  
  
   
Output content 2
  
  Default
 

Examples:

 
  
   
Administrator
  
  Visitors
 

Note:

The name attribute can use functions and system variables. The attribute value is the variable name without the $ symbol, and the value must contain the $ symbol when using the variable, as shown in the preceding example.

The value of value does not support simultaneous judgment of multiple conditions when the variable method is used, as shown in the following multi-condition judgment.

Multi-condition judgment:
The value Attribute of case can support simultaneous judgment of multiple conditions. Use the | symbol for segmentation:

 
  
   
Image Format File
  
  Other format files
 

This indicates that if $ _ GET ["type"] is set to gif, png, or jpg, the image format is used.

The name attribute can also be a system variable and a function can be used.Such:

 
  ......
 

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.