Variable reference count

Source: Internet
Author: User
Variable reference counting problem variable reference makes people get confused what reference, separation, write copy, write change ...... for example: & lt ;? Php $ a & nbsp; 1; $ B & nbsp; & amp; & nbsp; $ a; xdebug_debug_zval (a); debug_zval_dump ($ ); * result B: (refcount2, & nbsp; is_ref1), I variable reference count
Variable references make people go crazy.
What is the reference, separation, and replication during writing? changes during writing .....
For example:
 $ A = 1;
$ B = & $;

Xdebug_debug_zval ('A ');
Debug_zval_dump ($ );

/* Result
B:
(Refcount = 2, is_ref = 1), int 1

Long (1) refcount (1)
*/

The refcount test results are different. is xdebug accurate or built-in debug_zval_dump accurate?
------ Solution ----------------------
Call debug_zval_dump ($ a); when the form parameter and $ a are separated, call debug_zval_dump can be referred to the following situation

$ A = 1;

$ B = & $

$ C = $
------ Solution ----------------------
Reference http://www.laruence.com/2008/09/19/520.html
------ Solution ----------------------
The refcount in the report of the two functions is not a meaning
Please do not be confused by a thorough article.
------ Solution ----------------------
Reference:
Are these two functions used to view reference counts?


View the application count
Debug_zval_dump ($ a); use the reference method debug_zval_dump (& $ a). because your call is similar to the following situation, read/write splitting occurs. $ c has been separated from $.

$ A = 1;
$ B = & $
$ C = $

Xdebug_debug_zval is the reference count, while debug_zval_dump is the reference count + 1 because it transmits parameters to it.




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.