I'm writing a function where I want to pass a variable as reference, but I want it to be an optional argument.
This is what I want to do:
function foo($str1, &$str2='')
$str2 should be optional, but when supplied, I want to modify it. However, the
=''
part makes PHP spit out a parse error. If I only write
&$str2
, PHP will complain about "missing argument 2..."
I want $str2 to behave like the third argument in ereg() does. How can I do that?