#18684 [Opn->Ver]: Parser error when trying to create a new class instance in a static definition

From: Date: Thu, 01 Aug 2002 18:05:55 +0000
Subject: #18684 [Opn->Ver]: Parser error when trying to create a new class instance in a static definition
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15756@lists.php.net to get a copy of this message
ID: 18684 Updated by: nohn@php.net Reported By: michiwalter@gmx.de -Status: Open +Status: Verified Bug Type: Scripting Engine problem -Operating System: Windows 2000 +Operating System: Windows 2000, Tru64 -PHP Version: 4.2.1 +PHP Version: 4.2.1, 4.3.0-dev New Comment: Verified this "bug" with 4.3.0-dev on Compaq Tru64 though I can't see any sense in what you're trying to do. Previous Comments: ------------------------------------------------------------------------ [2002-08-01 10:53:19] michiwalter@gmx.de Summary: Parser error when trying to create a new class instance in a static definition. Error reproducable on: - Windows 2000/IIS/PHP 4.2.1 (CGI) - Windows 2000/Apache 1.3.24/PHP 4.2.0 - Linux deathrow 2.4.9-34/Apache 1.3.26/PHP 4.2.2 Test script: <?php class Test { }; function test() { static $var=new Test(); } ?> Error message: Parse error: parse error, unexpected T_NEW in __FILE__ on line __LINE__ Known workarounds: ... function test() { static $var=NULL; if(NULL===$var) $var=new Test(); return $var; } ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18684&edit=1

« previous php.bugs (#15756) next »