ID:               49096
 Comment by:       xiezhenye at gmail dot com
 Reported By:      xiezhenye at gmail dot com
 Status:           Open
 Bug Type:         JSON related
 Operating System: *
 PHP Version:      5.2.10
 New Comment:

addition:
it will apears when the properties are protected or private.


Previous Comments:
------------------------------------------------------------------------

[2009-07-29 09:28:00] xiezhenye at gmail dot com

Description:
------------
json_encode has side effect and may affect array propterty and cause
RECURSION.


Reproduce code:
---------------
class Test {
    protected $data;
    function __construct($data) {
        $this->data = $data;
    }
}
$t = new Test(array('a'=>1, 'b'=>2));
print_r($t);
json_encode($t);
print_r($t);


Expected result:
----------------
Test Object
(
    [data:protected] => Array
        (
            [a] => 1
            [b] => 2
        )

)
Test Object
(
    [data:protected] => Array
        (
            [a] => 1
            [b] => 2
        )

)

Actual result:
--------------
Test Object
(
    [data:protected] => Array
        (
            [a] => 1
            [b] => 2
        )

)
Test Object
(
    [data:protected] => Array
 *RECURSION*
)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49096&edit=1

Reply via email to