我有一个php智能标签的html页面。问题是{literal}
标签,需要转义javascript和css代码块。在许多其他php版本中,如php 5.3或5.5工作得很好,但在php 5.4.9不工作
当我使用{literal}
转义javascript时,如下所示:
<script type="text/javascript">
{literal}
$(function () {
jQuery.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) jQuery.support.placeholder = true;
if (!$.support.placeholder) {
$('.field').find ('label').show ();
}
});
{/literal}
</script>
我得到一个"Fatal error: Smarty error: [in login.html line 70]: syntax error: unrecognized tag: php' . str_repeat(" ", substr_count('{literal (Smarty_Compiler.class.php, line 446) in /var/www/library/smarty/Smarty.class.php on line 1095"
,第70行是代码{literal}
。
但是如果我删除{literal}
标签并使用{ldelim}
和{rdelim}
,这工作得很好,如:
<script type="text/javascript">
$(function () {ldelim}
jQuery.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) jQuery.support.placeholder = true;
if (!$.support.placeholder) {ldelim}
$('.field').find ('label').show ();
{rdelim}
{rdelim});
</script>
我不认为作为解决方案改变{ldelim}
和{rdelim}
项目中的所有标签{literal}
,当我有相同的项目在其他php版本中工作良好,当我有很多页面用{literal}
逃避javascript和css时。
当运行这个PHP版本时,这个Smarty版本似乎有一个错误。我建议你用最新的。如果你不能,你应该测试最新的Smarty 2.6.28来检查这个错误是否被删除,然后决定是否移动到这个Smarty版本。