I read that such a record will display deprecated :
class A{} $obj = &new A; But I tried it on my host and did not see anything (although I included all errors and warnings). Not the point!
The question is: what is the difference between creating an object by reference and without it?
PS A very interesting thing turned out
$obj = new A; xdebug_debug_zval('obj'); ///obj:(refcount=1, is_ref=0), object(A)[1] $obj = &new A; xdebug_debug_zval('obj'); ///obj:(refcount=1, is_ref=1), object(A)[1] I did not understand how is_ref=1 , when refcount=1 (usually is_ref=1 , when refcount>=2 )?
Another interesting point:
class A{} $obj = &new A; xdebug_debug_zval('obj'); ///obj:(refcount=1, is_ref=1), object(A)[1] $alter = &$obj; xdebug_debug_zval('obj'); ///obj:(refcount=2, is_ref=1), object(A)[1] unset($alter); xdebug_debug_zval('obj'); ///obj:(refcount=1, is_ref=0), object(A)[1] The meaning of the upper example is that we tied a variable to the created object, and then untied the freshly baked link, made to check whether is_ref=1 or not, as we see it zeroed out, but why it is not clear, we didn’t do anything with the original =)