smarty自定义函数
例如:
1)smarty 自定义函数assign
作用:用于在模版被执行的时候为模版变量赋值
函数名称:assign
参数:var :声明变量名称 字符串
value:给该变量赋值 字符串
<{ assig var="title" vale="this is title" }>=$tpl ->assign("title" , "this is title")
2)smarty方法assign
例如:<{title num ="10" content="aaa" size="10" color="red"}>
第一步:自定义函数
function fun1 ( ) { }
第二步:注册自定义函数
$tpl-> register_function("模版文件中的函数名" , “PHP中的函数名”)
注册块
$tpl - >register_block("模版文件中的块名",“PHP中的函数名”);
<{h num= 10 content = "aaa" }> <{/h}>
在plugins目录下新建文件
新建函数文件 world
例如:function.assign_debug_info.php
步骤:
第一步:plugins下新建文件function.world.php
第二步:打开文件
function smarty_function_world($args.&$smarty) {.......}