The problem cited by call_user_func_array.

<?php
class tests{
    public function __call($m, $args)
    {
        //$m = test
        call_user_func_array($m,$args);
    }

    // test..
    public function test(&$a){
        $a = $a + 1000;
    }
}

// run.
function test(&$a){
    $a PP;
}

$cls = new tests();

$a  = 100;
$cls->test($a);

//test($a); // 101

echo ($a);
?>

1: call_user_func_array calls its own methods first? No need to add class objects?
2: after removing the class test method, let it call the test function. Errors will be reported.
Warning: Parameter 1 to test () expected to be a reference, value given i

excuse me, how can I get it to call the reference function?

Php
Jul.17,2021

Don't you read the document? it says that call_user_func and call_user_func_array cannot pass parameters

by reference.
Menu