note 76029 added to language.oop5.iterations

From: Date: Wed, 27 Jun 2007 06:44:23 +0000
Subject: note 76029 added to language.oop5.iterations
Groups: php.notes 
Request: Send a blank email to php-notes+get-128015@lists.php.net to get a copy of this message
Beware there exists a rule in PHP to define all the classes that will be used before you write the code that instantiates the objects of those classes. The PHP manual says concerning the basics of classes (http://www.php.net/manual/en/language.oop5.basic.php): "Classes should be defined before instantiation (and in some cases this is a requirement)." This is particularly true if your class is implementing an interface. Suppose you have a class that implements nothing. If you instantize this class before its definition, it will work & the parser will not produce any problem. Simply adding "implements <interface_name>" to the class definition will result in a fatal error: "Class <your class name> not found" The only solution is to move the class definition before its instantiation. A bug report for this was also submitted by someone (http://bugs.php.net/bug.php?id=37753), which was declared bogus, as the PHP manual clearly states this requirement. ---- Server IP: 69.147.83.197 Probable Submitter: 59.94.247.80 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.iterations.php Edit -- https://master.php.net/note/edit/76029 Del: integrated -- https://master.php.net/note/delete/76029/integrated Del: useless -- https://master.php.net/note/delete/76029/useless Del: bad code -- https://master.php.net/note/delete/76029/bad+code Del: spam -- https://master.php.net/note/delete/76029/spam Del: non-english -- https://master.php.net/note/delete/76029/non-english Del: in docs -- https://master.php.net/note/delete/76029/in+docs Del: other reasons-- https://master.php.net/note/delete/76029 Reject -- https://master.php.net/note/reject/76029 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128015) next »