Created
September 22, 2016 21:11
-
-
Save MacDada/319b0ce50c627b9d311c15d43715dcae 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 | |
class Order | |
{ | |
public $user1; | |
public $user2; | |
} |
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 | |
$user = new User(); | |
$user->username = 'foo'; | |
$oder = new Order(); | |
$oder->user1 = $user; | |
$oder->user2 = $user; | |
var_dump($order->user1->username, $oder->user2->username); // oba zwrócą foo | |
$order->user1->username = 'bar'; | |
var_dump($order->user1->username, $oder->user2->username); // oba zwrócą bar, bo przecież user1 i user2 wskazują na ten sam obiekt |
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 | |
class User | |
{ | |
public $username; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment