|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-29 13:56 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 06:00:01 2025 UTC |
Description: ------------ In most (all?) other OOP-oriented languages, it's a common paradigm to define a class and provide a static member of the class in the definition and initialize it with a new object of the class. This is commonly used to implement singletons which are a must for many projects. This doesn't seem to work with PHP5. Reproduce code: --------------- <?php class Foo { static $me = new Foo(); public function __construct() { } } ?> Expected result: ---------------- Parse error: parse error, unexpected T_NEW in /u1/home/vlad/php/test/3.php on line 3 Actual result: -------------- created static member of the class with the initialized object