1,
example($node,$test1,$test2);
This will still pass the first parameter by reference, because the function definition states so. You don't need to use any special syntax here.
So to answer the could I use it
- Yes. That's actually how you should use it.
2,
example($node,$test1,$test2,$test3)
I assume this was a typo. The first parameter should still be noted as $node
, not &node
.
And it will still be passed as reference without any extra syntax.
The fourth parameter ($test3) will however be unknown within your original funciton. It will not have a name, because you didn't define the 4th param in you func declaration. In that case it will only be available as:
$test3 = func_get_arg(3);
If you want to pass any of the other parameters by reference, then you can use the special pass-by-ref on invocation syntax:
example($node, & $test1, & $test2);
This will give you an E_DEPRECATED warning on most setups. But it would still work as intended.
You only need the func( & $var )
syntax if you want to override what the function intended to be passed by reference per default.