note 76029 rejected from language.oop5.iterations by nicobn
| From: | nicobn@php.net | Date: | Fri, 13 Jul 2007 21:20:26 +0000 |
| Subject: | note 76029 rejected from language.oop5.iterations by nicobn | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128509@lists.php.net to get a copy of this message | ||
Note Submitter: singlarahul21 at gmail dot com
----
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.