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
The answer by @xdazz is correct, but just to add the following great example from the PHP Manual which gives an insight into what PHP is doing under the hood.
In this example you can see that $bar
within the function foo() is a static reference to a function scope variable.
Unsetting $bar
removes the reference but doesn't deallocate the memory:
The above example will output:
Before unset: 1, after unset: 23
Before unset: 2, after unset: 23
Before unset: 3, after unset: 23