Hello Todd,

Tuesday, October 19, 2004, 11:10:53 PM, you wrote:

> People keep calling the following invalid:

> function method(MyClass $param1=null, $param2)

> I'm way behind the times (running 4.3.6), but take a
> look at how 4.3.6 behaves!:

> <?
> function method($param1=null,$param2) {
>    print "$param1:$param2\n";
> }
> method(1,2);
> method(1);
?>>

> produces

> 1:2

> Warning: Missing argument 2 for method() in /tmp/badopt.php on line 2
> 1:
> Notice: Undefined variable:  param2 in /tmp/badopt.php on line 3

WOW! Funny error. Look again this does not support what you want
it is just a silly error in the compiler. If the code written would
do what it suggests then the second call would not raise an error
and instead return null:1. Currently both 4.3.9 and 5 result in an
error and set the second parameter to null regardless of the first
parameters default value. Also if we were to support this we'd need
to allow the following call:
method(,2); which would result in null:2

regards
marcus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to