Edit report at https://bugs.php.net/bug.php?id=61138&edit=1

 ID:                 61138
 Updated by:         ahar...@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

Reply via email to