[ create a new paste ] login | about

Link: http://codepad.org/dSnZ5I10    [ raw code | output | fork ]

PHP, pasted on Apr 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$old = new stdClass();
$old->foo = 'bar';
$old->baz = &$old;

print_r($old);

$new = unserialize(serialize($old));

$new->foo = 'new';

print_r($new);
print_r($new->baz->foo);


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
stdClass Object
(
    [foo] => bar
    [baz] => stdClass Object
 *RECURSION*
)
stdClass Object
(
    [foo] => new
    [baz] => stdClass Object
 *RECURSION*
)
new


Create a new paste based on this one


Comments: