|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53386 Allow use function or class for rvalue of static variable
Submitted: 2010-11-23 14:55 UTC Modified: 2010-11-24 15:34 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: lifinsky at yandex dot ru Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
34 - 12 = ?
Subscribe to this entry?

 [2010-11-23 14:55 UTC] lifinsky at yandex dot ru
Now language allow only constant for static variable in function (static $a = 0).
Please allow functionality such as in C++

Test script:
class testA {
	private function __constructor(){}
	public static function getInstance() {
		static $a = new testA();
		return $a;

	public function a() {
		return 5;

$a = testA::getInstance();
echo $a->a();

Expected result:

Actual result:
fatal error
PHP Parse error:  syntax error, unexpected T_NEW


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 15:34 UTC]
-Summary: Allow use funtion or class for rvalue of static variable +Summary: Allow use function or class for rvalue of static variable
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Sep 21 17:01:23 2020 UTC