note 92995 added to language.oop5.visibility

From: Date: Tue, 18 Aug 2009 21:06:14 +0000
Subject: note 92995 added to language.oop5.visibility
Groups: php.notes 
Request: Send a blank email to php-notes+get-159614@lists.php.net to get a copy of this message
Some Method Overriding rules : 1. In the overriding, the method names and arguments (arg’s) must be same. Example: class p { public function getName(){} } class c extends P{ public function getName(){} } 2. final methods can’t be overridden. 3. private methods never participate in the in the overriding because these methods are not visible in the child classes. Example: class a { private function my(){ print "parent:my"; } public function getmy(){ $this->my(); } } class b extends a{ private function my(){ print "base:my"; } } $x = new b(); $x->getmy(); // parent:my 4. While overriding decreasing access specifier is not allowed class a { public function my(){ print "parent:my"; } } class b extends a{ private function my(){ print "base:my"; } } //Fatal error: Access level to b::my() must be public (as in class a) ---- Server IP: 69.147.83.197 Probable Submitter: 71.190.79.121 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php Edit -- https://master.php.net/note/edit/92995 Del: integrated -- https://master.php.net/note/delete/92995/integrated Del: useless -- https://master.php.net/note/delete/92995/useless Del: bad code -- https://master.php.net/note/delete/92995/bad+code Del: spam -- https://master.php.net/note/delete/92995/spam Del: non-english -- https://master.php.net/note/delete/92995/non-english Del: in docs -- https://master.php.net/note/delete/92995/in+docs Del: other reasons-- https://master.php.net/note/delete/92995 Reject -- https://master.php.net/note/reject/92995 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159614) next »