Skip to content

Instantly share code, notes, and snippets.

@MacDada
Created September 22, 2016 21:11
Show Gist options
  • Save MacDada/319b0ce50c627b9d311c15d43715dcae to your computer and use it in GitHub Desktop.
Save MacDada/319b0ce50c627b9d311c15d43715dcae to your computer and use it in GitHub Desktop.
<?php
class Order
{
public $user1;
public $user2;
}
<?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
<?php
class User
{
public $username;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment