比如在tpl页面中我用了:onclick="<{$comdel}>" 
 
在PHP页面中我写的是:
$smarty->register_function('comdel', 'comdela');
function comdela($params, &$smarty)
{
 echo "<script>alert('1');</script>";
}
这样写为何不弹出1;请高手指点。

解决方案 »

  1.   

    onclick = '{comdela params="some value" smarty="some other value"}'
      

  2.   

    如果是全局函数或者是php系统函数的话可以这样用:
    {par1|函数名:par2:par3.....}
    比如:
    {$content|mb_strcut:0:800}
      

  3.   

    php:
    function add(str1,str2,int1){}smarty:
    {add str1='aa' str2='bb' int1=110}
      

  4.   


    php:
    $smarty->register_function('comdel', 'comdela');
    function comdela($params)
    {
    extract($params); echo "<script>alert($str1);</script>";
    }
    smarty:
    {comdel str1='aa' }
      

  5.   

    register_function 好像在smarty3里已经不被推荐使用