problem with different versions of php

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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?

Where would I find documentation on the differences in the versions of
php? Is there a good site? Maybe a table with a feature comparison?

Thanks for your help.

Re: problem with different versions of php

On 9 Nov 2006 22:04:54 -0800, wrote:

Quoted text here. Click to load it

 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
that says: "Note:  As of PHP 5, default values may be passed by reference."

Andy Hassall :: :: :: disk and FTP usage analysis tool

Site Timeline