|
Posted by Andy Hassall on 11/10/06 14:41
On 9 Nov 2006 22:04:54 -0800, herpers@wiso.uni-koeln.de wrote:
>I'm not sure where to look up the answer to this question myself, so
>maybe you can help me.
>
>The following line of code works fine with php5:
>
> function CheckMappings(&$badMappings=array())
>
>On a system with php4 the following error is thrown:
>
>Parse error: parse error, unexpected '=', expecting ')' in <phpfile> on
>line 42
>
>Now I would like to know, what the problem is. Is it the '&' or the
>default value assignment or a combination of both?
It's the default parameter as a reference that's not accepted in PHP 4.
i.e. the following two work on 4 and 5:
function CheckMappings($badMappings = array())
function CheckMappings(&$badMappings)
But the following, as you have it, only works on 5:
function CheckMappings(&$badMappings = array())
There's a note in
http://www.php.net/manual/en/functions.arguments.php#functions.arguments.default
that says: "Note: As of PHP 5, default values may be passed by reference."
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|