note 16448 added to keyword.parent
| From: | Terry at herckenrath dot net | Date: | Wed, 31 Oct 2001 04:31:35 +0000 |
| Subject: | note 16448 added to keyword.parent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19689@lists.php.net to get a copy of this message | ||
I've been having problems with '$par = get_parent_class($this);' -
get_parent_class($this) seems to always return the parent class of outermost class definition - for
instance:
class A {
function A($v1, $v2) {
echo "A\n";
}
}
class B extends A {
function B($v1, $v2) {
$par = get_parent_class($this);
echo $par."\n";
$this->$par($v1, $v2);
}
}
class C extends B {
function C($v1, $v2) {
$par = get_parent_class($this);
echo $par."\n";
$this->$par($v1, $v2);
}
}
$test = new C("xxx", "yyy");
causes the following infinite output:
B
B
B
B
B
B
B
(You don't actually see this output because the browser will not display the page due to the
looping...)
Terry
--
http://www.php.net/manual/en/keyword.parent.php
http://master.php.net/manage/user-notes.php?action=edit+16448
http://master.php.net/manage/user-notes.php?action=delete+16448
http://master.php.net/manage/user-notes.php?action=reject+16448