<分区>
Possible Duplicate:
Is it possible to pass parameters by reference using call_user_func_array()?
我有以下代码行在 PHP 5.1 中有效,但在 PHP 5.3 中无效。
$input = array('ss','john','programmer');
call_user_func_array(array($mysqli_stmt, 'bind_param'), $input);
在 PHP 5.3 中,我收到以下警告消息:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /var/www/startmission/em/class/cls.data_access_object.php on line 785
我将代码更改为以下并且它有效:
$a = 'johnl';
$b = 'programmer';
$mysqli_stmt->bind_param('ss',$a,$b);
我在 php 文档中找到了这个:
Care must be taken when using mysqli_stmt_bind_param() in conjunction with call_user_func_array(). Note that mysqli_stmt_bind_param() requires parameters to be passed by reference, whereas call_user_func_array() can accept as a parameter a list of variables that can represent references or values.
所以我的问题是,如何复制 call_user_func_array + bind_params 的功能,以便我可以在运行时动态绑定(bind)变量?