0
$test = 'aaaaaa';
$abc = & $test;
unset($test);
echo $abc;

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

2 Answers 2

6

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.