Home > Article > Backend Development > thinkphp uses literal to prevent template tags from being parsed, thinkphpliteral_PHP tutorial
The example in this article describes how thinkphp outputs directly without parsing tags to prevent template tags from being parsed. Share it with everyone for your reference. The specific implementation method is as follows:
You can use literal tags in ThinkPHP to prevent template tags from being parsed, for example:
The above if tag is included in the literal tag, so the content in the if tag will not be parsed by the template engine, but will be output as is.
If your php tag needs to output something like {$user} or XML tag, you can solve the confusion problem by adding a literal tag, for example:
The {$Think in this php tag may be mistakenly parsed as a tag by the template engine. The solution is to add literal, for example:
Literal tags can also be used in the outer layer of the JS code of the page to ensure that certain usages in the JS code are not confused with the template engine.
In short, all possible conflicts with the parsing rules of the built-in template engine can be handled using literal tags.
I hope this article will be helpful to everyone’s ThinkPHP framework programming.