The reference count of phpnull is 0.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.