ID: 29015 Updated by: [EMAIL PROTECTED] Reported By: tomas_matousek at hotmail dot com -Status: Verified +Status: Closed Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2005-03-06 New Comment:
Fixed in CVS HEAD and PHP_5_0. Empty property and string properties started with '\0' are disallowed. Previous Comments: ------------------------------------------------------------------------ [2004-08-14 00:43:06] php at hristov dot com AFAUK, internally the private member variables are stored in such a way that the first byte is \0, which maybe you emulate with your test case. ":private" means that the member var is private one. shorter example for "creating" of a private variable : php -r '$a=new stdclass();$a->$b=3;var_dump($a);' and of "integer" member variable php -r '$a=new stdclass();$b=3;$a->$b=3;var_dump($a);' andrey ------------------------------------------------------------------------ [2004-07-05 15:02:12] tomas_matousek at hotmail dot com Description: ------------ If I try to use variable with non-string name (e.g. $x = 10; $$x = ...) the name is converted to a string using standard conversion rules. That's ok. But this doesn't work on object's field which is IMHO a bug and it implies some a buggy behavior. See the code bellow. It seems that by: $x = null; $a->$x = "whatever"; one can somehow create a private variable (or something like that, don't know what ":private" means)! Moreover, there is possibly a bug in get_object_vars when a field name is a numeric string (e.g. "10") (compare the first item of results of get_object_vars and var_dump). Reproduce code: --------------- function field_names_test() { $a = new stdClass(); $x = 10; $a->$x = "int(10)"; $x = "10"; $a->$x = "string('10')"; $x = ""; $a->$x = "string('')"; $x = null; $a->$x = "null"; $x = 1.8; $a->$x = "double(1.8)"; $x = false; $a->$x = "bool(false)"; $x = array(1,2,3); $a->$x = "array(1,2,3)"; var_dump(get_object_vars($a)); var_dump($a); } field_names_test(); Expected result: ---------------- array(4) { ["10"]=> string(12) "string('10')" [""]=> string(11) "bool(false)" ["1.8"]=> string(11) "double(1.8)" ["Array"]=> string(12) "array(1,2,3)" } object(stdClass)#1 (4) { ["10"]=> string(12) "string('10')" [""]=> string(11) "bool(false)" ["1.8"]=> string(11) "double(1.8)" ["Array"]=> string(12) "array(1,2,3)" } Actual result: -------------- array(3) { [10]=> string(12) "string('10')" ["1.8"]=> string(11) "double(1.8)" ["Array"]=> string(12) "array(1,2,3)" } object(stdClass)#1 (4) { ["10"]=> string(12) "string('10')" [":private"]=> string(11) "bool(false)" ["1.8"]=> string(11) "double(1.8)" ["Array"]=> string(12) "array(1,2,3)" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29015&edit=1