Bug #61138 [Opn->Nab]: convert object
| From: | aharvey@php.net | Date: | Sun, 19 Feb 2012 06:19:40 +0000 |
| Subject: | Bug #61138 [Opn->Nab]: convert object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167622@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61138&edit=1
ID: 61138
Updated by: aharvey@php.net
Reported by: uginroot at gmail dot com
Summary: convert object
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Windows 7
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
As documented at http://au2.php.net/manual/en/language.types.array.php,
integer
properties in objects that are cast to an array are inaccessible.
Previous Comments:
------------------------------------------------------------------------
[2012-02-19 05:57:34] uginroot at gmail dot com
Description:
------------
$product = json_decode('{"name":"Anton","1":"is not
null"}');
print_r($product);
var_dump($product->name);
var_dump($product->{'1'});
$product = (array)$product;
print_r($product);
var_dump($product['name']);
var_dump($product['1']);
Test script:
---------------
<?php
$product = json_decode('{"name":"Anton","1":"is not
null"}');
print_r($product);
var_dump($product->name);
var_dump($product->{'1'});
$product = (array)$product;
print_r($product);
var_dump($product['name']);
var_dump($product['1']);
Expected result:
----------------
stdClass Object
(
[name] => Anton
[1] => is not null
)
string(5) "Anton"
string(11) "is not null"
Array
(
[name] => Anton
[1] => is not null
)
string(5) "Anton"
string(11) "is not null"
Actual result:
--------------
stdClass Object
(
[name] => Anton
[1] => is not null
)
string(5) "Anton"
string(11) "is not null"
Array
(
[name] => Anton
[1] => is not null
)
string(5) "Anton"
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61138&edit=1