- 论坛徽章:
- 0
|
下面这个例子来自Smarty手册,函数print_current_date的声明中的&$smarty参数有什么用?函数主体中根本没有到啊?哪位解释一下呢?
<?php
// load Smarty library
require_once('d:\apache\php\libs\Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'd:/apache/Apache2/smarty/guestbook/templates/';
$smarty->compile_dir = 'd:/apache/Apache2/smarty/guestbook/templates_c/';
$smarty->config_dir = 'd:/apache/Apache2/smarty/guestbook/configs/';
$smarty->cache_dir = 'd:/apache/Apache2/smarty/guestbook/cache/';
$smarty->register_function('date_now', 'print_current_date');
function print_current_date($params, &$smarty)
{
if(empty($params['format'])) {
$format = "%b %e, %Y";
} else {
$format = $params['format'];
}
return strftime($format,time());
}
$smarty->display('register_function.tpl');
?> |
|