note 42153 added to keyword.parent
| From: | ckrack at i-z dot de | Date: | Wed, 05 May 2004 13:39:51 +0000 |
| Subject: | note 42153 added to keyword.parent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69232@lists.php.net to get a copy of this message | ||
Note that we can use $this in the parent's method like we might expect.
It will be used as the instance of the extended class.
<?php
class foo {
var $x;
function foofoo()
{
$this->x = "foofoo";
return;
}
}
class bar extends foo {
// we have var $x; from the parent already here.
function barbar()
{
parent::foofoo();
echo $this->x;
}
}
$b = new bar;
$b->barbar(); // prints: "foofoo"
?>
----
Manual Page -- http://www.php.net/manual/en/keyword.parent.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42153
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42153&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42153&report=yes
Search -- http://master.php.net/manage/user-notes.php