Jcart wrote:Code: Select all
function test( &$param1 = null ) {
$param1 is already passed by reference, no need.
As for your other, why do have have curly brackets around your varname. Double quotes allows you to parse variables within the string.
There isn't a parse error so I don't really know what to say, except it must be another line nearby.
No, I need to pass $param1 by reference, but I get an error when I put '( &$param1 = null )'. I can remove the '&' and it produces no error, but the variable isn't by reference anymore. I cannot use global scope for reference handeling because what is being passed to it could be any random variable name. Also, I am pretty sure all variables are passed by value in php5 by default.
The other is a matter of coding preference, but I guess it can change...
Something just hit me, maybe php4.3 doesn't allow function declarations of by-ref, but instead you pass by-ref when calling the function:
Code: Select all
function test( $a ) {
$a++;
}
$b = 5;
test( $b );
test( &$b );
echo $b;
Though that is against php5's methods of doing things, and I think it will raise a warning...