modifiers标量调节器插件的定义和使用

在插件目录plugins里新建文件 modifier.插件名.php文件(如 modifier.插件名.php)
例:function smarty_modifier_test($utime, $format){
return date($format,$utime);
}
tpl中新建datetime.html,内容:
{$time|test:'Y-m-d H:i:s'}

index.php内容如下:

<?php
require('../smarty/Smarty.class.php');
$smarty = new Smarty();
//五配置
$smarty->left_delimiter = "{"; 
$smarty->right_delimiter = "}";
$smarty->template_dir ="tpl";
$smarty->compile_dir ="template_c";
$smarty->cache_dir ="cache";
//开启缓存的另两个配置
$smarty->caching =true;
$smarty->cache_lifetime =120;
$smarty->assign('time',time()); $smarty->display('datetime.html'); ?>

  

原文地址:https://www.cnblogs.com/family-626-77/p/5737315.html