Advertisement
P22DX

Reference.php

Jan 6th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.26 KB | None | 0 0
  1. <?php
  2. class MyClass
  3. {
  4.     public int $property;
  5.  
  6. }
  7.  
  8. $obj = new MyClass();
  9. $obj->property = 1;
  10. $normal = $obj->property;
  11. $reference = &$obj->property; // always have same value
  12. $obj->property = 2; // update new value
  13.  
  14. echo $normal . PHP_EOL;
  15. echo $reference . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement