note 20583 added to keyword.parent

From: Date: Tue, 09 Apr 2002 02:41:59 +0000
Subject: note 20583 added to keyword.parent
Groups: php.notes 
Request: Send a blank email to php-notes+get-28990@lists.php.net to get a copy of this message
Here is the workaround I came up with based on the comments about using a 'constructor' method and the parent:: syntax... #cat test.php <?php class foo { function foo() { $this->constructor(); } function constructor() { echo get_class($this)." (foo)\n"; } } class bar extends foo { function bar() { $this->constructor(); } function constructor() { echo get_class($this)." (bar)\n"; parent::constructor(); } } class baz extends bar { function & baz() { $this->constructor(); } function & constructor() { echo get_class($this)." (baz)\n"; parent::constructor(); } } $o = new baz; ?> #php test.php X-Powered-By: PHP/4.1.2 Content-type: text/html baz (baz) baz (bar) baz (foo) # -- 'a' -> 'o' in email TLD -- http://www.php.net/manual/en/keyword.parent.php http://master.php.net/manage/user-notes.php?action=edit+20583 http://master.php.net/manage/user-notes.php?action=delete+20583 http://master.php.net/manage/user-notes.php?action=reject+20583

« previous php.notes (#28990) next »