If a function has not been defined to take optional arguments, then you
*must* provide these arguments when you call the function.  The fact that
previous versions of PHP incorrectly let you do this was at best an
undocumented misfeature, but more likely a bug.

And yes, having optional arguments with the default value defined in the
function definition is perfectly acceptable.

-Rasmus

On Sat, 14 Apr 2001, Chris Aitken wrote:

> On Fri, 13 Apr 2001, Hardy Merrill wrote:
>
> >I found the same problem - when we upgraded to PHP4, function calls
> >that used to work and NOT provide all the parameters, started failing.
> >
> >The way I fixed it was to give each parameter a default value *IN*
> >the function definition, like:
> >
> >function abc($a='', $b='') // assigns null as parameter defaults
> >
> >that way, every parameter gets a value, even if all the parameters
> >were not supplied in the call.
> >
>
> This works great (thanks for that :). However my question now is, what is
> the general opinion about how to handle this.
>
> Is it better to call functions giving all arguments values (even if its an
> empty "" value) or is it fine to assign values from within the function as
> described above ?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to