A PHP parsing error occurs when the smarty template engine is applied in the project today. It is mainly located in the CSS section, and the error is shown as "uncaught
Exception 'smartycompilerexception' with message' syntax error in
Template ". After careful analysis, we found that HTML-embedded CSS
{} The curly braces conflict with the definition symbol {} of the smarty. If you embed the CSS Tag into the header of the HTML document, the "Unrecognized tag" error will occur, you can find three solutions to solve this problem:
1. External link CSS file.Use link external links to cascade style sheet files. For example:
<Link href = "style.css" type = "text/CSS" rel = "stylesheet"/>
2.
Use literal flag.Use the literal tag unique to smarty to identify areas that do not need to be parsed. Use the region tag {literal} and {/literal} to skip the analysis and output directly, this will not cause conflicts.
{Literal} <style type = "text/CSS"> body {color: # fff ;}</style >{/ literal}
3.
Modify the default delimiter of smarty.This goal is achieved by setting the left_delimiter and right_delimiter attributes.
Require ("Smarty. Class. php"); $ template = new smarty; $ template-> left_delimiter = '<{'; $ template-> right_delimiter = '}> ';
The disadvantage of the 3rd method is that you need to modify the parsing tag of the original template, which is troublesome. We recommend 1st and 2nd flexible combinations.