note 113103 added to language.oop5.references
| From: | akam at akameng dot com | Date: | Thu, 29 Aug 2013 21:30:41 +0000 |
| Subject: | note 113103 added to language.oop5.references | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196123@lists.php.net to get a copy of this message | ||
Object is being referenced even after the original object deleted, so be careful when copying
objects into your array.
<?php
$result = json_decode(' {"1":1377809496,"2":1377813096}');
$copy1['object'] = $result;
$copy2['object'] = $result;
unset($result);
//now lets change $copy1['object'][1] to 'test';
$copy1['object']->{"1"} = 'test';
echo ($copy1 === $copy2) ? "Yes" : "No";
print_r($copy2);
/*
Array
(
[API] => stdClass Object
(
[1] => test
[2] => 1377813096
)
)
*/
?>
----
Server IP: 69.147.83.199
Probable Submitter: 130.193.211.69
----
Manual Page -- http://php.net/manual/en/language.oop5.references.php
Edit -- https://master.php.net/note/edit/113103
Del: integrated -- https://master.php.net/note/delete/113103/integrated
Del: useless -- https://master.php.net/note/delete/113103/useless
Del: bad code -- https://master.php.net/note/delete/113103/bad+code
Del: spam -- https://master.php.net/note/delete/113103/spam
Del: non-english -- https://master.php.net/note/delete/113103/non-english
Del: in docs -- https://master.php.net/note/delete/113103/in+docs
Del: other reasons-- https://master.php.net/note/delete/113103
Reject -- https://master.php.net/note/reject/113103
Search -- https://master.php.net/manage/user-notes.php