note 61174 added to language.oop5.paamayim-nekudotayim

From: Date: Fri, 27 Jan 2006 11:57:07 +0000
Subject: note 61174 added to language.oop5.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-102555@lists.php.net to get a copy of this message
You use 'self' to access this class, 'parent' - to access parent class, and what will you do to access a parent of the parent? Or to access the very root class of deep class hierarchy? The answer is to use classnames. That'll work just like 'parent'. Here's an example to explain what I mean. Following code <?php class A { protected $x = 'A'; public function f() { return '['.$this->x.']'; } } class B extends A { protected $x = 'B'; public function f() { return '{'.$this->x.'}'; } } class C extends B { protected $x = 'C'; public function f() { return '('.$this->x.')'.parent::f().B::f().A::f(); } } $a = new A(); $b = new B(); $c = new C(); print $a->f().'<br/>'; print $b->f().'<br/>'; print $c->f().'<br/>'; ?> will output [A] -- {B} -- (C){C}{C}[C] ---- Server IP: 195.54.192.44 Probable Submitter: 213.147.37.165 (proxied: unknown) ---- Manual Page -- http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61174 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61174&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61174&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102555) next »