note 35223 added to keyword.parent
| From: | hustbaer at rack1 dot php dot net | Date: | Sun, 24 Aug 2003 03:37:33 +0000 |
| Subject: | note 35223 added to keyword.parent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54981@lists.php.net to get a copy of this message | ||
something on the note of 'minoc':
in this setup, the "$this->$par();" will lead to infinite recursion...
class foo extends bar {
function foo() {
$par = get_parent_class($this);
$this->$par();
// then normal constructor stuff.
// ...
}
function bar()
{
echo "this makes no sense, but who cares :)";
}
}
but the problem is easity fixed by going like so:
class foo extends bar {
function foo() {
$par = get_parent_class($this);
parent::$par();
// then normal constructor stuff.
// ...
}
function bar()
{
echo "this makes no sense, but who cares :)";
}
}
----
Manual Page -- http://www.php.net/manual/en/keyword.parent.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35223
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35223&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35223&report=yes