background image

and all the contents are the same obviously.

4.
function set2(&$s){
$var = $s;
}
set2($var1) results:
*var1 passing to the function, and *s is the same as *var1,
but when $var = $s executes, from 1. we can see @var is the same as @s, 
but *var is different from *s, so @var and @s is not in the same memory area,
while @s and @var1 is sharing the same memory area, also *var1 and *s are the same.

5.
normal function return:
function get(){ return $var1; }
assuming the result is referred by a variable $result.
then @result is copied from @var1 but *result is not the same as *var1
when $var = get();
first you get a variable $result, as I said above, @result is the same as @var1, but *result
is different from *var1, and next $var = $result executes. 
As I said in 1., you can find, @var is the same as @result and the same as @var1, 
but *var is different from *result AND *var1;

while $var =& get() just means:
*var is the same as *result, so @var and @result are in the same memory area, 
but they are still different from those of $var1, 
both the memory area of @var1 and *var1,

6.
returning by referrence
function &get(){ return $var1; }
there are two ways to get the result

$var = get(); and $var =& get(); now I will tell the difference
I. $var = get();
the *result is the same as *var1 and so @result and @var1 are the same.
and then $var = $result executes, 
*var is not the same as *result, and also different from *var1, 
but their contents are the same.

I. $var =& get();