|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-05-12 12:59 UTC] mike@php.net
-Status: Open
+Status: Bogus
[2010-05-12 12:59 UTC] mike@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 12:00:01 2025 UTC |
Description: ------------ When an object with a __set() method has its non-existent array containing variable set by empty bracket syntax, it just creates a new object variable for the array, as if __set() weren't even there. Test script: --------------- <?php class Foo { public $_vars = array(); public function __set($var, $value) { $this->_vars[$var] = $value; } } $foo = new Foo; $foo->bar[] = 'value'; var_dump($foo); ?> Expected result: ---------------- __set() method called object(Foo)#1 (1) { ["_vars"]=> array(1) { ["bar"]=> array(1) { [0]=> string(5) "value" } } } OR <br /> <b>Fatal error</b>: Cannot use [] for reading in <b>/home/amcsi/htdocs/lol.php</b> on line <b>11</b><br /> Actual result: -------------- object(Foo)#1 (2) { ["_vars"]=> array(0) { } ["bar"]=> array(1) { [0]=> string(5) "value" } }