The example of this article describes the method of thinkphp label direct output to prevent template tags from being parsed. Share to everyone for your reference. The implementation methods are as follows:
You can use the literal tag in thinkphp to prevent template tags from being parsed, for example:
Copy Code code as follows:
<literal>
<if condition= "$name eq 1" > value1
<elseif condition= "$name eq 2"/>value2
<else/> Value3
</if>
</literal>
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 kept as-is output.
If you need to output a situation like {$user} or XML tags in your PHP tags, you can solve the confusion by adding literal tags, such as:
Copy Code code as follows:
<php>echo ' {$Think. Config.custom. ' $key. '} '; </php>
The {$Think in this PHP tag may be mistakenly interpreted as a label by the template engine, and the solution is to add literal, for example:
Copy Code code as follows:
<php><literal>echo ' {$Think. Config.custom. ' $key. '} '; </literal></php>
Literal tags can also be used for the page's JS code outer layer, to ensure that some of the use of JS code and template engine does not create confusion.
All in all, the literal tag can be used where all possible conflicts with the parsing rules of the built-in template engine.
I hope this article will be helpful to everyone's thinkphp framework program design.