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