|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-25 16:19 UTC] cataphract@php.net
-Assigned To:
+Assigned To: cataphract
[2011-11-25 17:01 UTC] cataphract@php.net
[2011-11-25 17:01 UTC] cataphract@php.net
-Status: Assigned
+Status: Duplicate
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 22:00:01 2025 UTC |
Description: ------------ An object loses access to property with numeric key when it was created by casting from array. But string keys are ok. Why???? Test script: --------------- <?php $o = new stdClass; $o->{0} = 'Hello World'; print_r($o); print_r(get_object_vars($o)); echo($o->{0} . "\n"); $o = (object)array(0 => 'Hello World'); print_r($o); print_r(get_object_vars($o)); echo($o->{0} . "\n"); ?> Expected result: ---------------- stdClass Object ( [0] => Hello World ) Array ( [0] => Hello World ) Hello World stdClass Object ( [0] => Hello World ) Array ( [0] => Hello World ) Hello World Actual result: -------------- stdClass Object ( [0] => Hello World ) Array ( [0] => Hello World ) Hello World stdClass Object ( [0] => Hello World ) Array ( ) PHP Notice: Undefined property: stdClass::$0 in ...