note 42378 added to keyword.parent
| From: | andyfaeglasgowTAKE_ME_OUT at yahoo dot co dot uk | Date: | Fri, 14 May 2004 00:15:35 +0000 |
| Subject: | note 42378 added to keyword.parent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69589@lists.php.net to get a copy of this message | ||
re: referring to a parents variables
The documentation doesn't say anything about how one should refer to the variables of a parent
class in a child class (maybe it's obvious but I thought I'd point it out anyway).
class Actress {
var $bust;
function Actress() {$this->bust = "32C";}
function show() {echo "Bust: $this->bust...";}
}
class HollywoodActress extends Actress{
var $attitude;
function HollywoodActress () {
$this->Actress();
$this->attitude = "Fiery";
}
function show() {
parent::show();
echo "Attitude: $this->attitude";
}
function modify_bust() {
$this->bust = "32DD";
}
}
$girl_at_theatre = new Actress();
$girl_at_theatre->show();
//output: "Bust: 32C..."
$object_of_gossip = new HollywoodActress();
$object_of_gossip->modify_bust();
$object_of_gossip->show();
//output: "Bust: 32D:...Attidude: Fiery"
----
Manual Page -- http://www.php.net/manual/en/keyword.parent.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42378
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42378&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42378&report=yes
Search -- http://master.php.net/manage/user-notes.php