PHP升级5.3之后,因为参数传递与5.2有所区别,在函数调用的时候更为严格
具体体现在call_user_func_array对引用参数的判定上
function foo (&$param){
echo $param->a;
}
class a {
public $a;
function __construct(){
$this->a = ‘test’;
}
}
$a =new a();
call_user_func_array(‘foo’,array($a)); //5.2正确,5.3出错
call_user_func_array(‘foo’,array(&$a));//正确的用法
这导致了按照网上例程中smarty在register resource的时候会导致错误
网上的例程:
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj){
}
//用于smarty从数据库中读取模板
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj){
}
//用于smarty从数据库中读取模板
function db_get_secure($tpl_name, &$smarty_obj){
}
//用于smarty从数据库中读取模板
function db_get_trusted($tpl_name, &$smarty_obj){
}
因为在smarty_internal_resource_registered.php中调用资源注册函数时传递的smarty对象为非引用的
所以在写smarty资源注册函数时对smarty_obj对象参数的传递时应当注意
function db_get_template ($tpl_name, &$tpl_source, $smarty_obj){
}
//用于smarty从数据库中读取模板
function db_get_timestamp($tpl_name, &$tpl_timestamp, $smarty_obj){
}
//用于smarty从数据库中读取模板
function db_get_secure($tpl_name, $smarty_obj){
}
//用于smarty从数据库中读取模板
function db_get_trusted($tpl_name, $smarty_obj){
}
