The explanation in the manual is: a simple reference (in other words, "become its alias" or "point to") the original variable. Changing the new variable will affect the original variable and vice versa.
I understand the reference to a person who has taken two names, whether it's a name or a person.
The following two example results are all the same. Deleting or modifying will affect the value of another variable.
!--? php
$foo =
' Bob ' ;
// assigns
' Bob ' to
$foo
$bar = &
$foo ;
// with
$bar reference
$foo
$bar =
"My name is $bar" ;
// modify
$bar variable echo
$bar ; echo
$foo ;
// The value of
$foo has also been modified?>!--? php
$foo =
' Bob ' ;
// assigns
' Bob ' to
$foo
$bar = &
$foo ;
// with
$bar reference
$foo
$foo =
"My name is $bar" ;
// modify
$foo variable echo
$bar ,
"\ n" ; echo
$foo ;
// The value of
$foo has also been modified?
When you delete a reference, either deleting b or a result does not affect the other variable. Just the equivalent of deleting a name without affecting the variable itself.
0;$b = &$a; // echo$a; //0 unset($bunset$bunset($aunset$becho$b; //0 it's OK
When a variable refers to two variables successively, the first reference variable is modified to the second reference. The first reference has no relationship and does not affect each other.
$a = "hihaha";$b = &$a;$c = "eita";$b = &$c;echo$b; // shows "hihaha"
The invocation of a function's address call, executed, is equivalent to changing the referenced variable directly. Over here b the real of the pass-through function is a The memory address where the variable contents of B are located, by changing in the function the value of a can be changed B's value.
functiontest( &$a ){$a10; return$a;}$b1;test($b);echo$b;//输出11
A reference to the function returns
function &test2(){ $b 0;//申明一个静态变量 $b = $b+1; return$b;}$a = test2();//这条语句会输出 $b的值 为1var_dump($a);$a = test2();//这条语句会输出 $b的值 为2var_dump($a);$a = & test2();//这条语句会输出 $b的值 为3var_dump($a);$a5;$a = test2();//这条语句会输出 $b的值 为6var_dump($a);
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the PHP variable reference assignment some knowledge, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.