首頁  >  文章  >  後端開發  >  smarty如何使用外部函數?

smarty如何使用外部函數?

autoload
autoload原創
2021-03-08 17:26:052022瀏覽

  1.系統函數使用:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
        {strlen(&#39;helloworld&#39;)}//在模板中需要对函数使用一个相应的边界符{}。
</body>
</html>

  2.自訂函數使用:

<html>  //smarty.html 模板
    <header></header>
    <body>
        {SpeakHello()}
    </body>
</html>
<?php

include &#39;smarty/Smarty.class.php&#39;;//实例化Smarty
$smarty = new Smarty();


function SpeakHello(){       //必须在模板加载入内存之前
    echo "hello";
}

$smarty->display(&#39;smarty.html&#39;);
?>

推薦:php教學,php影片教學

#

以上是smarty如何使用外部函數?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn