开发者

php code analysis

开发者 https://www.devze.com 2022-12-09 22:27 出处:网络
$test = \'aaaaaa\'; $abc = & $test; unset($test); ec开发者_如何学Pythonho $abc; It outputs \'aaaaaa\',which is already unset,can you explain this?No, it unsets $test, but the value is not delete
$test = 'aaaaaa';
$abc = & $test;
unset($test);
ec开发者_如何学Pythonho $abc;

It outputs 'aaaaaa',which is already unset,can you explain this?


No, it unsets $test, but the value is not deleted because there is another reference to it, namely $abc.


When you call:

$abc =& $test;

It points $abc at the same object in memory that $test is pointing at. It doesn't point $abc at $test - there's a subtle difference.

This means you can destroy $test, but $abc will still be pointing at the object in memory, so the value is not destroyed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号