note 80949 added to keyword.parent

From: Date: Fri, 08 Feb 2008 03:48:46 +0000
Subject: note 80949 added to keyword.parent
Groups: php.notes 
Request: Send a blank email to php-notes+get-135889@lists.php.net to get a copy of this message
I've noticed that when you call a parent constructor in a child class, you must call the parent::__construct() method last, otherwise the ops following that call will not be evaluated by the interpreter. Example: class A { __construct() { echo 'hello'; } } class B extends A { __construct() { parent::__construct(); echo ' world'; } } $b = new B(); This prints 'hello'. It DOES NOT print 'hello world' like I expected. Is this normal? ---- Server IP: 203.202.10.60 Probable Submitter: 71.6.35.10 ---- Manual Page -- http://www.php.net/manual/en/keyword.parent.php Edit -- https://master.php.net/note/edit/80949 Del: integrated -- https://master.php.net/note/delete/80949/integrated Del: useless -- https://master.php.net/note/delete/80949/useless Del: bad code -- https://master.php.net/note/delete/80949/bad+code Del: spam -- https://master.php.net/note/delete/80949/spam Del: non-english -- https://master.php.net/note/delete/80949/non-english Del: in docs -- https://master.php.net/note/delete/80949/in+docs Del: other reasons-- https://master.php.net/note/delete/80949 Reject -- https://master.php.net/note/reject/80949 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135889) next »