PHP null reference count 0 problem

Source: Internet
Author: User
Many on the Web say $ A = NULL is a direct null for the data structure pointed to by $ A, and its reference count to 0.

But my test found that it did not return 0, the code is as follows:

$s=str_repeat('1',2);  //这和第二个例子完全相同  $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 is still 2, and it's not classified as 0, and I don't know why.

Reply content:

Many on the Web say $ A = NULL is a direct null for the data structure pointed to by $ A, and its reference count to 0.

But my test found that it did not return 0, the code is as follows:

$s=str_repeat('1',2);  //这和第二个例子完全相同  $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 is still 2, and it's not classified as 0, and I don't know why.

$s=nullAfter this sentence is executed, S and P point to the object is null, the object's RefCount is 2, a little bit of a problem.

  • 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.