RE: [PHP] Function overloading bug?

From: Date: Mon, 18 Sep 2000 22:46:38 +0000
Subject: RE: [PHP] Function overloading bug?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-33456@lists.php.net to get a copy of this message
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@sziisoft.com] > Sent: den 18 september 2000 18:53 > To: php-general@lists.php.net; php-dev@lists.php.net > 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@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.dev (#33456) next »