note 86648 deleted from language.oop5.static by bjori
| From: | bjori@php.net | Date: | Tue, 28 Oct 2008 11:35:13 +0000 |
| Subject: | note 86648 deleted from language.oop5.static by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145859@lists.php.net to get a copy of this message | ||
Note Submitter: Marceaux
Reason: bad code
----
@zerocool: __construct() cannot be private or protected, it needs to be public (at least in PHP
5.2.6). You can make it private/protected in the class definition, but the moment you actually try
to instantiate an object you'll get a fatal error:
PHP Fatal error: Call to protected/private Foo::__construct() from invalid context
Same goes for __destruct() (will get you a warning), __clone() (fatal error) and other magic
functions.
As a side effect, this means __construct() & the rest can be accessed freely and directly from
outside the object. Sad but true.