Skip to content

Instantly share code, notes, and snippets.

@MacDada

MacDada/Order.php

Created Sep 22, 2016
Embed
What would you like to do?
<?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