note 48234 added to language.oop5.static
| From: | michael at digitalgnosis dot removethis dot com | Date: | Thu, 16 Dec 2004 07:41:05 +0000 |
| Subject: | note 48234 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81846@lists.php.net to get a copy of this message | ||
Here's another way to do the same thing (see my post below) without having to muck up your
Foo() function's parameters in the Base and all Derived classes.
However, you cannot use static, and still must define Foo() in derived classes. This way also
performs slower and may not always work--but it DOES make for prettier code.
<?php
class Base
{
function Foo ()
{
$call = debug_backtrace();
call_user_func(array($call[1]['class'],'Bar'));
}
}
class Derived extends Base
{
function Foo () { parent::Foo(); }
function Bar ()
{
echo "Derived::Bar()";
}
}
Derived::Foo();
?>
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48234
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48234&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48234&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48234&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48234&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48234&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48234&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48234&report=yes
Search -- http://master.php.net/manage/user-notes.php