Edit report at https://bugs.php.net/bug.php?id=65585&edit=1
ID: 65585 Updated by: ahar...@php.net Reported by: kylekatarnls at gmail dot com Summary: Cannot access empty property : Why not ? -Status: Open +Status: Not a bug Type: Feature/Change Request Package: *General Issues PHP Version: 5.4.19 Block user comment: N Private report: N New Comment: This is by design: the fix for bug #52484 made empty properties inaccessible to avoid silent data loss when an empty property was set in __set(). At any rate, I'm not sure there's a good argument for supporting empty properties â object properties and array keys aren't strictly analogous in PHP, and casting between arrays and objects can result in data loss in other ways as it is. Previous Comments: ------------------------------------------------------------------------ [2013-08-29 17:04:28] kylekatarnls at gmail dot com Description: ------------ Why can we not access property with empty name ? I wish be able to do something like this : $object->{""} = "Foo"; echo $object->{""}; Actualy, we can do : $array = (array) $object; $array[""] = "Foo"; echo $array[""]; $object = (object) $array; So why could we not set and get the value of an property with empty name ? Test script: --------------- $object->{""} = "Foo"; echo $object->{""}; Expected result: ---------------- print Foo and throw any error or just a notice. Actual result: -------------- Fatal error : Cannot access empty property ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65585&edit=1