|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-05 07:41 UTC] torben@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 13:00:02 2026 UTC |
Description: ------------ Somehow initializing properties has it's limitations. I think my example should have worked just fine (it would've worked in Java C# and a lot of other language). However, the limitation is there, but I can't find it in the documentation! I think it should be under both Classes and Objects (PHP 4) and Classes and Objects (PHP 5). Reproduce code: --------------- <?php class TestClass { public static function somefunc() { return 'somevalue'; } public static $someProperty = TestClass::somefunc(); // PARSE ERROR protected static $singleton = new TestClass(); // PARSE ERROR public $someVar = new TestClass(); // PARSE ERROR } Expected result: ---------------- No errors or limitations documented. Actual result: -------------- Parse error: syntax error, unexpected '(', expecting ',' or ';' in D:\www\binding\test.php on line 6 Parse error: syntax error, unexpected T_NEW in D:\www\binding\test.php on line 7 Parse error: syntax error, unexpected T_NEW in D:\www\binding\test.php on line 8