Created
November 1, 2018 07:13
-
-
Save timotheemoulin/500eaea488b3c8535b99e2d7db21e2b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$foo = new StdClass(); | |
$foo->bar = new StdClass(); | |
$foo->bar->baz = 'toto'; | |
// this contains the main object | |
var_dump($foo); | |
$bar = $foo->bar; | |
$bar->bak = 'bak'; | |
// the sub object has been updated as expected | |
var_dump($bar); | |
// the main object has been updated too because $bar contains a reference to $foo->bar | |
var_dump($foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment