Use of ThinkPHPIF labels

Source: Internet
Author: User
If the above labels cannot meet the condition judgment requirements, we can also use the if label to define complex condition judgment.

If the above labels cannot meet the condition judgment requirements, we can also use the if label to define complex condition judgment.

If tag (condition-based tag)
Close Non-closed labels
Attribute Condition (required): condition to be judged
Elseif tag)
Close Close tags
Attribute Condition (required): condition to be judged
Else tag (conditional judgment tag)
Close Close tags
Attribute None

Usage example:

  1. Value1
  2. Value2
  3. Value3

In the condition attribute, you can support 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:

  1. Value1
  2. Value2

Must be changed:

  1. Value1
  2. Value2

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

  1. ThinkPHP
  2. Other Framework

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

  1. ThinkPHP
  2. Other Framework

Or you know that the user variable is an object.

  1. ThinkPHP
  2. Other Framework

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.

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.