PHP pass by reference/value - question
<p>I was going to explain to our intern the difference between "pass by reference" and "pass by value" in PHP, and did this simple script:</p>

<pre><code>$a=5; 
$b=&amp;$a; 
$a=8; 
echo $b;
// prints  8
$a=5; 
$b=$a;  //no &amp;
$a=8; 
echo $b;
// prints 5
</code></pre>

<p>However, running this in php-cli using php -qa yields: </p>

<pre><code>php &gt;     $a=5; 
php &gt;     $b=&amp;$a; 
php &gt;     $a=8; 
php &gt;     echo $b;
8
php &gt;     // prints  8
php &gt;     $a=5; 
php &gt;     $b=$a;  //no &amp;
php &gt;     $a=8; 
php &gt;     echo $b;
8
php &gt;     // prints 5
</code></pre>

<p>Should not the <code>$b=$a;</code> unlink $a and $b?</p>

<p>... so I got curius, and tried: </p>

<pre><code>php &gt; $b=3;
php &gt; echo $a;
3
</code></pre>

<p>So, how did I get this wrong? What's going on here? It seems the reference-setting is somehow sticking, even though it should be cleared at the line <code>$b=$a</code>? I also tried: </p>

<pre><code>php &gt;    $e=5; $f=$e; $e=6; echo $f; 
5
</code></pre>

<p>...Which works as expected. </p>

<p><code>$a</code> and <code>$b</code> seems linked permanently? Am I missing some big point here? How do I "unlink" the <code>$a</code> and <code>$b</code> variable?</p>
