1

I can't comprehend the refcount that debug_zval_dump() print.

<?php
    $str = "test function";
    $sr1 = '';
    $str1 = & $str;

    debug_zval_dump($str);

The output of the above code: string(13) "test function" refcount(1)

when i delete the ampersand before the $str:

<?php
    $str = "test function";
    $sr1 = '';
    $str1 =  $str;

    debug_zval_dump($str);

The output of the above code :string(13) "test function" refcount(3)

what has happened ? The first refcount is "1".But, i think it also referenced three times.

李德康
  • 15
  • 6
  • 1
    Possible duplicate of [Why the refcount is 2 not 1?](http://stackoverflow.com/questions/4221645/why-the-refcount-is-2-not-1) – JYoThI Nov 03 '16 at 05:34

1 Answers1

0

Because a copy of $str is being made, when the function is called.

MySelfBoy
  • 33
  • 2