[PHP-DEV] RE: [PHP] Function overloading bug? From: Steeve Lennmark (jaster <email protected>)
Date: 09/18/00

Maybe im stupid but should you really have two functions with the same name
in the class?
One takes 2 arguments, the other takes 3.

> -----Original Message-----
> From: Szii [mailto:szii <email protected>]
> Sent: den 18 september 2000 18:53
> To: php-general <email protected>; php-dev <email protected>
> Subject: [PHP] Function overloading bug?
>
>
> Against the latest "release," the following does not work
> correctly for me...
>
> <?php
> class foo
> {
> function foo()
> {
> }
>
> function writeit($text,$length)
> {
> echo $text . " " . $length;
> }
>
> function writeit($text, $outText, $length)
> {
> echo $outText;
> $this->writeit($text,$length); // does not
> evaluate properly
> }
>
> }
>
> $a = new foo();
> $a->writeit("hi","out",2);
>
> ?>
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> Warning: Missing argument 3 for writeit() in
> /home/websites/sziisoft.com/index.php4 on line 18
>
> <repeat forever>
>
> The 2nd writeit() makes a call to $this->writeit() and evaluates itself in
> the context of itself, instead of within the context of the class. ie, it
> tries to call itself instead of evaluating against the class, finding the
> "2 parameter method," and using it. This then generates a warning
> about an unused $outText and calls itself recursively, and infinitely.
>
> Anyone else noticed this?
>
> -Szii
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe <email protected>
> For additional commands, e-mail: php-general-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>