smarty使用外部函数的方法

2023-05-26,

这篇文章主要介绍smarty使用外部函数的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

 1.系统函数使用:

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

 2.自定义函数使用:

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

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


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

$smarty->display('smarty.html');
?>

以上是“smarty使用外部函数的方法”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注本站行业资讯频道!

《smarty使用外部函数的方法.doc》

下载本文的Word格式文档,以方便收藏与打印。