Created
February 28, 2017 17:47
-
-
Save ilhamarrouf/793c46ebf5db914a1e058c20f48e9fac to your computer and use it in GitHub Desktop.
OOP PHP
This file contains hidden or 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 A | |
{ | |
public $foo = 1; | |
} | |
$a = new A; | |
$b = $a; // $a and $b are copies of the same identifier | |
// ($a) = ($b) = <id> | |
$b->foo = 2; | |
echo $a->foo."\n"; | |
$c = new A; | |
$d = &$c; // $c and $d are references | |
// ($c,$d) = <id> | |
$d->foo = 2; | |
echo $c->foo."\n"; | |
?> | |
// Result | |
2 | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment