Open
Description
在下面这篇文章中:
https://github.com/pangudashu/php7-internal/blob/master/2/zval.md
有个demo:
$a = "time:" . time(); //$a -> zend_string_1(refcount=1)
$b = $a; //$a,$b -> zend_string_1(refcount=2)
$c = $b; //$a,$b,$c -> zend_string_1(refcount=3)
unset($b); //$b = IS_UNDEF $a,$c -> zend_string_1(refcount=2)
我用php7.0实际运行的结果是:
<?php
$a = "time:" . time(); //$a -> zend_string_1(refcount=1)
debug_zval_dump($a);
$b = $a; //$a,$b -> zend_string_1(refcount=2)
$c = $b; //$a,$b,$c -> zend_string_1(refcount=3)
debug_zval_dump($a);
unset($b); //$b = IS_UNDEF $a,$c -> zend_string_1(refcount=2)
debug_zval_dump($a);
输出:
string(15) "time:1629940681" refcount(2)
string(15) "time:1629940681" refcount(4)
string(15) "time:1629940681" refcount(3)
想请教下,是什么原因导致了这种差异?
Metadata
Metadata
Assignees
Labels
No labels