|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27059 Variable with empty name can be made
Submitted: 2004-01-27 10:17 UTC Modified: 2004-01-29 09:57 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: uno at venus dot dti dot ne dot jp Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4CVS, 5CVS OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-01-27 10:17 UTC] uno at venus dot dti dot ne dot jp
Variable or object property can be made with empty name.
This behaviour doesn't match the manual.
Variable names follow the same rules as other labels in PHP.
A valid variable name starts with a letter or underscore,
followed by any number of letters, numbers, or underscores.
As a regular expression, it would be expressed thus:
A class is a collection of variables and functions working
with these variables.

Reproduce code:

${''} = 'abc';
echo ${''};

class X{
$x = new X;
$x->{''} = 'def';
echo $x->{''};

Expected result:
Error. (warning or notice are acceptable for me)

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-28 21:37 UTC]
It would be too slow to add checks for the various strange 
things you can do inside {}, simply because these checks 
would need to occur realtime vs script parsing time. 
 [2004-01-29 00:00 UTC] uno at venus dot dti dot ne dot jp
When you read ${''} (or $x->{''}) without assigning, PHP notices 'Undefeined variable(property): in ...' on current implementation. So I suppose that checks need to be added only when assiging new dynamic variable and performance problem may be not too heavy.
 [2004-01-29 09:13 UTC]
No matter how much it would slow down the exection, I 
think we ought to maintain the backwards compatibility 
as I know there are several scripts that depend on the 

 [2004-01-29 09:57 UTC] uno at venus dot dti dot ne dot jp
Sure. I understand backward compatibility is important. Accuracy of language specification also.
If development team take this behaviour not a bug, I suppose that definition of variable name in the manual needs a little more clarification.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Aug 11 05:05:45 2022 UTC