Function overloading bug?
| From: | Szii | Date: | Mon, 18 Sep 2000 16:52:32 +0000 |
| Subject: | Function overloading bug? | ||
| Groups: | php.dev php.general | ||
| Request: | Send a blank email to php-general+get-17146@lists.php.net to get a copy of this message | ||
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