note 27486 added to keyword.parent
| From: | anonymous at cowards dot com | Date: | Sat, 07 Dec 2002 18:48:29 +0000 |
| Subject: | note 27486 added to keyword.parent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40488@lists.php.net to get a copy of this message | ||
Um, reading through all the gyrations on getting C++ constructor
semantics from PHP, I am wondering if I am just blindly missing something
when I use:
class A {
function A () { echo "A Constructor\n"; }
}
class B extends A {
function B () { $this->A (); echo "B Constructor\n"; }
}
class C extends B {
function C () { $this->B (); echo "C Constructor\n"; }
}
$c = new C ();
produces:
A Constructor
B Constructor
C Constructor
I'm new to PHP, but it seems to me that this is simpler and cleaner
than the solutions discussed here, with the only disadvantage being that
when you change the name of your superclass you have to change one
line in your subclass.
What am I missing? Are there advanced PHP-OO considerations that
make this code undesireable??
--
http://www.php.net/manual/en/keyword.parent.php
http://master.php.net/manage/user-notes.php?action=edit+27486
http://master.php.net/manage/user-notes.php?action=delete+27486
http://master.php.net/manage/user-notes.php?action=reject+27486