note 42378 deleted from keyword.parent by derick

From: Date: Wed, 31 Aug 2016 15:04:13 +0000
Subject: note 42378 deleted from keyword.parent by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206432@lists.php.net to get a copy of this message
Note Submitter: andyfaeglasgowTAKE_ME_OUT at yahoo dot co dot uk ---- 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"

« previous php.notes (#206432) next »