开发者

Why does Smarty replace things like '%>' with <?php echo '%>'; ?> and how to avoid this?

开发者 https://www.devze.com 2023-02-14 19:57 出处:网络
Im optimizing a Smarty template and things are looking good but the only thing left is that the resulting cached template is littered with things like 开发者_高级运维<?php echo \'%>\'; ?> whe

Im optimizing a Smarty template and things are looking good but the only thing left is that the resulting cached template is littered with things like 开发者_高级运维<?php echo '%>'; ?> where it should just have '%>'.

It does the same for '?>' but that's understandable as it would confuse PHP, does '%>' have the same effect?


As you point out, it does the same for the more traditional closing tag ?>.

Well, %> is a PHP closing tag too, albeit one disabled by default. You'd activate it with asp-tags:

Enables the use of ASP-like <% %> tags in addition to the usual tags. This includes the variable-> value printing shorthand of <%= $value %>. For more information, see Escaping from HTML.

Smarty's just being thorough. Unfortunately, it's not doing a very good job of it. Make sure that this is disabled and your problems should go away.


Take a look at the asp-tags ini setting:

asp_tags boolean

Enables the use of ASP-like <% %> tags in addition to the usual tags. This includes the variable-> value printing shorthand of <%= $value %>. For more information, see Escaping from HTML.

In newer php versions this is turned off by default so if smarty changes those i wouldn't be surprised. (If i understood you correctly)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号