Home >Backend Development >PHP Problem >How to use external functions in smarty?
1. System function usage:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> {strlen('helloworld')}//在模板中需要对函数使用一个相应的边界符{}。 </body> </html>
2. Custom function usage:
<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'); ?>
Recommended: php tutorial,php video tutorial
The above is the detailed content of How to use external functions in smarty?. For more information, please follow other related articles on the PHP Chinese website!