PHP Globals and Reference Difference Confusion
<p>Could some one please explain to me what the difference in the following is:</p>

<pre><code>$var = 'something';
function myFunc(){
    global $var;
    // do something
}
</code></pre>

<p>and (note: the reference sign &amp;)</p>

<pre><code>$var = 'something';
function myFunc(&amp;$var){
    // do something
}
</code></pre>

<p>I can't understand the difference between these two methods.</p>

<p><strong>Update</strong>  </p>

<p>Hmmm... I think i'm getting alittle confused here :)</p>

<pre><code>$var = 1;
$var2 = 2;
function myFunction(){
    global $var, $var2;
    $var = $var + $var2;
}
</code></pre>

<p><em>// echo $var would return 3 here.</em></p>

<hr>

<pre><code>$var = 1;
$var2 = 2;
function myFunction(&amp;$a, &amp;$b){
    $a = $a + $b;
}
</code></pre>

<p><em>// echo $var would return 3 here aswell.</em></p>

<hr>

<p>I understand those part already, But what i don't understand is the difference between these two approaches, am i wrong to assume that these two approaches are technically the same thing, with different concept of how they are wrote by the coder and also how they are handled by PHP?</p>

<p>If i'm wrong to assume this, then it would really help if you could provide better examples, maybe something that can be accomplished using only one of the above approaches?</p>

<p>ok, i noticed one difference while writing <em>This Update</em>, which is that when doing references i can chose new variable names while keeping the pointer to the variable in the functions scope.</p>
