note 77852 added to language.oop

From: Date: Sun, 16 Sep 2007 02:18:33 +0000
Subject: note 77852 added to language.oop
Groups: php.notes 
Request: Send a blank email to php-notes+get-130528@lists.php.net to get a copy of this message
Seems you can't access a class object from the parent class in the extended class. Is this a bug? Is there a work-around? <?php $a = new A(); $c = new C(); class A { var $b; function A() { $this->b = new B(); $this->b->say(); // Works } } class B { var $say; function B() { $this->say = 'wee'; } function say() { echo "saying: ". $this->say; } } class C extends A { function C() { $this->b->say(); // Throws error "Call to a member function on a non-object" } } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 68.105.79.175 ---- Manual Page -- http://www.php.net/manual/en/language.oop.php Edit -- https://master.php.net/note/edit/77852 Del: integrated -- https://master.php.net/note/delete/77852/integrated Del: useless -- https://master.php.net/note/delete/77852/useless Del: bad code -- https://master.php.net/note/delete/77852/bad+code Del: spam -- https://master.php.net/note/delete/77852/spam Del: non-english -- https://master.php.net/note/delete/77852/non-english Del: in docs -- https://master.php.net/note/delete/77852/in+docs Del: other reasons-- https://master.php.net/note/delete/77852 Reject -- https://master.php.net/note/reject/77852 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130528) next »