Home > Backend Development > PHP Tutorial > thinkphp uses literal to prevent template tags from being parsed, thinkphpliteral_PHP tutorial

thinkphp uses literal to prevent template tags from being parsed, thinkphpliteral_PHP tutorial

WBOY
Release: 2016-07-13 10:13:22
Original
1029 people have browsed it

thinkphp uses literal to prevent template tags from being parsed, thinkphpliteral

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:

Copy code The code is as follows:

value1
value2
value3

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:

Copy code The code is as follows:
echo '{$Think.config.CUSTOM.'.$key.'}';< ;/php>

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:

Copy code The code is as follows:
echo '{$Think.config.CUSTOM.'.$key.' }';

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/916064.htmlTechArticlethinkphp uses literal to prevent template tags from being parsed, thinkphpliteral This article describes an example of thinkphp not parsing tags and outputting them directly to prevent The method by which template tags are parsed. Share to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template