#18684 [NEW]: Parser error when trying to create a new class instance in a static definition
| From: | michiwalter at gmx dot de | Date: | Thu, 01 Aug 2002 14:53:19 +0000 |
| Subject: | #18684 [NEW]: Parser error when trying to create a new class instance in a static definition | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-15741@lists.php.net to get a copy of this message | ||
From: michiwalter@gmx.de
Operating system: Windows 2000
PHP version: 4.2.1
PHP Bug Type: Variables related
Bug description: Parser error when trying to create a new class instance in a static definition
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 bug report at http://bugs.php.net/?id=18684&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18684&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18684&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18684&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18684&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18684&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18684&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18684&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18684&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18684&r=globals