If you want to call a function by name or pass the parameter, call_user_func_array will be used to call a function with a known name. & nbsp; but it will not be used to call the instantiated class... class & nbsp; class_a {public & nbsp; $ var_a = & nbsp; 0; public & nbsp; fun
Call_user_func_array will be used to call a function with a known name, but the instantiated class will not be called...
class class_a
{
public $var_a= 0;
public function fun_1 ( $var )
{
var_dump( $this->var_a + $var );
}
};
$obj_a= new class_a();
$obj_a->var_a= 6;
call_user_func_array( array( 'class_a', 'fun_1' ), array( 5 ) );
Two errors will be reported. one is call_user_func_array, which calls non-static methods. The other two are not allowed to appear in the uninstantiated class.
In fact, the two errors in call_user_func_array are well understood...
There are other methods that can call the member functions of the instantiated class by using the function name, and pass parameters of an indefinite number... call_user_func_array to share the information:
------ Solution --------------------
class class_a
{
public $var_a= 0;
public function fun_1 ( $var )
{
var_dump( $this->var_a + $var );
}
};
$obj_a= new class_a();
$obj_a->var_a= 6;
call_user_func_array( array($obj_a, 'fun_1' ), array( 5 ) );
Let's take a look.