#27059 [WFx]: Variable with empty name can be made

From: Date: Thu, 29 Jan 2004 05:00:42 +0000
Subject: #27059 [WFx]: Variable with empty name can be made
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54106@lists.php.net to get a copy of this message
ID: 27059 User updated by: uno at venus dot dti dot ne dot jp Reported By: uno at venus dot dti dot ne dot jp Status: Wont fix Bug Type: Scripting Engine problem Operating System: * PHP Version: 4CVS, 5CVS New Comment: Fmm... 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. Previous Comments: ------------------------------------------------------------------------ [2004-01-28 21:37:59] iliaa@php.net 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-27 10:17:09] uno at venus dot dti dot ne dot jp Description: ------------ Variable or object property can be made with empty name. This behaviour doesn't match the manual. http://www.php.net/manual/en/language.variables.php 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-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' http://www.php.net/manual/en/language.oop.php A class is a collection of variables and functions working with these variables. Reproduce code: --------------- <?php error_reporting(E_ALL); ${''} = 'abc'; echo ${''}; class X{ } $x = new X; $x->{''} = 'def'; echo $x->{''}; ?> Expected result: ---------------- Error. (warning or notice are acceptable for me) Actual result: -------------- abcdef ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27059&edit=1

« previous php.bugs (#54106) next »