On the Internet, $ anull directly sets the data structure pointed to by $ a to null and returns the reference count to 0. However, my test found that the value is not 0. The Code is as follows: {code ...} print Output: {code ...} the refcount or 2 is not classified as 0. I don't know why $ a = null directly sets the data structure pointed to by $ a on the Internet, at the same time, the reference count is 0.
However, my test found that the value is not 0. The Code is as follows:
$ S = str_repeat ('1', 2); // This is exactly the same as the second example $ p = & $ s; $ s = null; xdebug_debug_zval ('s ', 'P ');
Print Output:
S :( refcount = 2, is_ref = 1), nullp :( refcount = 2, is_ref = 1), null
The refcount or 2 is not classified as 0. I don't know why
Reply content:
On the Internet, $ a = null directly sets the data structure pointed to by $ a to null, and returns the reference count to 0.
However, my test found that the value is not 0. The Code is as follows:
$ S = str_repeat ('1', 2); // This is exactly the same as the second example $ p = & $ s; $ s = null; xdebug_debug_zval ('s ', 'P ');
Print Output:
S :( refcount = 2, is_ref = 1), nullp :( refcount = 2, is_ref = 1), null
The refcount or 2 is not classified as 0. I don't know why
$ S = nullAfter this statement is executed, the s and p points to the null object, and the refcount of this object is 2. There is no problem at all.