note 93743 added to language.oop5.visibility

From: Date: Fri, 25 Sep 2009 10:04:23 +0000
Subject: note 93743 added to language.oop5.visibility
Groups: php.notes 
Request: Send a blank email to php-notes+get-161045@lists.php.net to get a copy of this message
Please note that protected methods are also available from sibling classes as long as the method is declared in the common parent. This may also be an abstract method. In the below example Bar knows about the existence of _test() in Foo because they inherited this method from the same parent. It does not matter that it was abstract in the parent. <?php abstract class Base { abstract protected function _test(); } class Bar extends Base { protected function _test() { } public function TestFoo() { $c = new Foo(); $c->_test(); } } class Foo extends Base { protected function _test() { echo 'Foo'; } } $bar = new Bar(); $bar->TestFoo(); // result: Foo ?> ---- Server IP: 64.71.164.2 Probable Submitter: 83.80.23.86 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php Edit -- https://master.php.net/note/edit/93743 Del: integrated -- https://master.php.net/note/delete/93743/integrated Del: useless -- https://master.php.net/note/delete/93743/useless Del: bad code -- https://master.php.net/note/delete/93743/bad+code Del: spam -- https://master.php.net/note/delete/93743/spam Del: non-english -- https://master.php.net/note/delete/93743/non-english Del: in docs -- https://master.php.net/note/delete/93743/in+docs Del: other reasons-- https://master.php.net/note/delete/93743 Reject -- https://master.php.net/note/reject/93743 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161045) next »