求教各位Smarty高手,我在Smarty中直接嵌入PHP代码,老报错,我也将$php_handling设置为应许了,急,急,希望高手指点! 

解决方案 »

  1.   

    哪里,里面是能够嵌入PHP代码的!
      

  2.   

    {php}
    echo $a;
    {/php}or<?php
    echo $a;
    ?>
      

  3.   

    使用smarty3得了  直接支持PHP函数
      

  4.   

    恩,是的,我是用{php}echo $a {/php}的形式啊,但是莫名其妙,总是保错!
      

  5.   

    悲哀啊,用<?php echo $a;?>的形式也不行啊!
      

  6.   

    如下错误:Fatal error: Uncaught exception 'Exception' with message '{php} is deprecated, set allow_php_tag = true to enable' in D:\PHP\AppServ\www\CaoCao\system\Smarty\libs\plugins\block.php.php:22 Stack trace: #0 D:\PHP\AppServ\www\CaoCao\system\Smarty\demo\templates_c\ea0e0e479320a435394b1239520064fb533da961.file.test.htm.php(25): smarty_block_php(Array, NULL, Object(Smarty), true, Object(Smarty_Internal_Template)) #1 D:\PHP\AppServ\www\CaoCao\system\Smarty\libs\sysplugins\smarty_internal_template.php(408): include('D:\PHP\AppServ\...') #2 D:\PHP\AppServ\www\CaoCao\system\Smarty\libs\sysplugins\smarty_internal_template.php(525): Smarty_Internal_Template->renderTemplate() #3 D:\PHP\AppServ\www\CaoCao\system\Smarty\libs\Smarty.class.php(331): Smarty_Internal_Template->getRenderedTemplate() #4 D:\PHP\AppServ\www\CaoCao\system\Smarty\libs\Smarty.class.php(373): Smarty->fetch('test.htm', NULL, NULL, NULL, true) #5 D:\PHP\AppServ\www\CaoCao\system\Smarty\demo\test.php(15): Smarty->display('test.htm') #6 {main} thrown in D:\PHP\AppServ\www\CaoCao\system\Smarty\libs\plugins\block.php.php on line 22
      

  7.   

    各位仁兄,经过多次试验和查找答案,问题终于得以解决:原来有一个变量叫$allow_php_tag,该变量必须设置为“true”,即$Smarty->allow_php_tag=true;然后就可以直接解析放在{php}{/php}中的代码了!多谢大家的参与!
      

  8.   

      那个$Smarty->allow_php_tag在哪的