No, the problem is that the first parameter of the function is passed by reference (this means that the function can change the argument in the callerβs area). Therefore, you must pass a variable or something that can be assigned as the first argument. When you create an array of type array($a) , it simply copies the value of the variable $a (which is 0) to the slot in the array. It does not refer to the $a variable in any way. And then when you call the function, it is as if you were doing this, which does not work:
test(0)
If you really want to, you can put $a in an array by reference, but it's pretty complicated:
<?php $a = 0; $args = array(&$a); function test(&$a) { $a++; } call_user_func_array('test', $args); ?>
As for how you would say that an array element is a reference ... it's complicated. You can do var_dump() in the array and find the "&" character:
> var_dump($args); array(1) { [0]=> &int(1) }
newacct
source share