Created
August 17, 2017 12:38
-
-
Save kana/ebf4d8daa52d6289e77c25ad2342ffd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = 1; | |
debug_zval_dump($a); | |
//==> long(1) refcount(2) | |
// Novice: Huh? Why is refcount 2? The value is only pointed by $a, so refcount must be 1! | |
// Tatsujin: PHP uses copy-on-write. The value is passed by value to debug_zval_dump. | |
// It doesn't modify the passed value. The value is shared by $a and debug_zval_dump. | |
// Therefore refcount is 2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment