note 47465 added to language.oop5.overloading
| From: | bigtree at DONTSPAM dot 29a dot nl | Date: | Wed, 17 Nov 2004 09:47:59 +0000 |
| Subject: | note 47465 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80631@lists.php.net to get a copy of this message | ||
Keep in mind that the __call method will not be called if the method you are calling actually
exists, even if it exists in a parent class. Check the following example:
<?php
class BaseClass
{
function realMethod()
{
echo "realMethod has been called\n";
}
}
class ExtendClass extends BaseClass
{
function __call($m, $a)
{
echo "virtual method " . $m . " has been called\n";
}
}
$tmpObject = new ExtendClass();
$tmpObject->virtualMethod();
$tmpObject->realMethod();
?>
Will output:
virtual method virtualMethod has been called
realMethod has been called
You might expect that all method calls on ExtendClass will be handled by __call because it has no
other methods, but this is not the case, as the example above demonstrates.
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47465
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47465&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47465&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47465&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47465&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47465&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47465&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47465&report=yes
Search -- http://master.php.net/manage/user-notes.php