note 48335 added to keyword.parent

From: Date: Mon, 20 Dec 2004 01:59:55 +0000
Subject: note 48335 added to keyword.parent
Groups: php.notes 
Request: Send a blank email to php-notes+get-82064@lists.php.net to get a copy of this message
An example for using a memberfunction with another memberfunction. The sequencing for the creating of the class is important. <?php class A { function example() { echo "I am A::example() and provide basic functionality.<br>\n"; } } class B extends A { function example() { echo "I am B::example() and provide additional functionality.<br>\n"; parent::example(); } } class C extends A { function example() { global $b; echo "I am c::example() and provide additional functionality.<br>\n"; parent::example(); $b->example(); } } $b = new B(); $c = new C(); $c->example(); ;?> Result: I am c::example() and provide additional functionality. I am A::example() and provide basic functionality. I am B::example() and provide additional functionality. I am A::example() and provide basic functionality. ---- Manual Page -- http://www.php.net/manual/en/keyword.parent.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48335 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48335&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48335&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48335&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48335&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48335&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48335&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48335&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82064) next »