note 101995 added to language.oop5.visibility

From: Date: Sat, 22 Jan 2011 00:41:35 +0000
Subject: note 101995 added to language.oop5.visibility
Groups: php.notes 
Request: Send a blank email to php-notes+get-175987@lists.php.net to get a copy of this message
In reply to ryan dot m dot lange: The behavior of your ChildClass2 class is exactly what should be expected. The constructor of ChildClass2 is not setting ParentClass::foo because that member is private and not visible to ChildClass2. Instead, it is dynamically defining and setting a new public $child2->foo member. $child2->foo() outputs nothing because foo() is inherited from ParentClass and the private ParentClass::foo member is unset. ParentClass's constructor is not automatically invoked by PHP since ChildClass2 defines its own constructor. ChildClass2::__construct() would have to explicitly invoke parent::__construct() if you wanted to chain constructors. $child2->bar() outputs the value of $child2->foo since that is the member that is visible to $child2. ---- Server IP: 69.147.83.197 Probable Submitter: 144.188.24.25 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php Edit -- https://master.php.net/note/edit/101995 Del: integrated -- https://master.php.net/note/delete/101995/integrated Del: useless -- https://master.php.net/note/delete/101995/useless Del: bad code -- https://master.php.net/note/delete/101995/bad+code Del: spam -- https://master.php.net/note/delete/101995/spam Del: non-english -- https://master.php.net/note/delete/101995/non-english Del: in docs -- https://master.php.net/note/delete/101995/in+docs Del: other reasons-- https://master.php.net/note/delete/101995 Reject -- https://master.php.net/note/reject/101995 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175987) next »