thinkphp using literal to prevent template labels from being parsed, thinkphpliteral_php tutorial

Source: Internet
Author: User

Thinkphp uses literal to prevent template labels from being parsed, thinkphpliteral


In this paper, we describe the method that thinkphp does not parse the direct output of the label to prevent the template label from being parsed. Share to everyone for your reference. The implementation method is as follows:

You can use literal tags in thinkphp to prevent template labels from being parsed, such as:
Copy the Code code as follows:
Value1
value2
Value3

The IF tag above is included with the literal tag, so the contents of the IF tag are not parsed by the template engine, but are output as-is.

If you need to output something like {$user} or XML tags in your php tag, you can solve the confusion by adding literal tags, for example:
Copy the code as follows: Echo ' {$Think. Config.custom. $key. '} ';

The {$Think in this PHP tag may be mistaken for tag parsing by the template engine, and the workaround is to add literal, for example:
Copy the code as follows: Echo ' {$Think. Config.custom. $key. '} ';

Literal tags can also be used in the page's JS code outer layer, to ensure that some of the JS code usage and template engine is not confusing.

In summary, all of the possible conflicts with the parsing rules of the built-in template engine can be handled using literal tags.

It is hoped that this article will be helpful to everyone's thinkphp framework design.

http://www.bkjia.com/PHPjc/916064.html www.bkjia.com true http://www.bkjia.com/PHPjc/916064.html techarticle thinkphp use literal to prevent template labels from being parsed, thinkphpliteral This article describes a method that thinkphp not parse the direct output of the label to prevent the template label from being parsed. Share to ...

  • 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.