Guest User

Strange PHP Behaviour

a guest
Feb 8th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $a =& new Book('test1');
  2. $b = $a;
  3. debug_zval_dump($b);
  4.  
  5. $c =& new Book('test2');
  6. $d = &$c;
  7. debug_zval_dump($d);
  8.  
  9. /*
  10. Output:
  11.  
  12. Deprecated: Assigning the return value of new by reference is deprecated in /var/www/y/y.php on line 35
  13.  
  14.  
  15. Deprecated: Assigning the return value of new by reference is deprecated in /var/www/y/y.php on line 39
  16.  
  17. object(Book)#1 (1) refcount(2){   <--- !!!
  18.   ["title":protected]=>
  19.   string(5) "test1" refcount(1)
  20. }
  21. object(Book)#1 (1) refcount(1){   <--- !!!
  22.   ["title":protected]=>
  23.   string(5) "test1" refcount(1)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment