PHP 删除“引用"从一个变量.

问题描述:

我有下面的代码.我想更改 $b 以再次使用它的值.如果我这样做,它也会改变 $a .之前将值分配为 $a 的引用后,如何再次为 $b 分配值?

I have the code below. I want to change $b to use it again with values. If I do so it changes $a as well. How can I assign a value to $b again after previously assigning it as a reference to $a?

$a = 1;
$b = &$a;

// later
$b = null;

查看内嵌说明

$a = 1;    // Initialize it
$b = &$a;  // Now $b and $a becomes same variable with just 2 different names  
unset($b); // $b name is gone, vanished from the context  But $a is still available  
$b = 2;    // Now $b is just like a new variable with a new value. Starting new life.