-
The transfer of parameters can be divided into two types of transmission value and address, what is the difference?
12345678910 |
function fun(
$num1
,
$num2
)
{
$num1
=100;
$num2
=1000;
}
$n1
=1;
$n2
=10;
fun(
$n1
,
$n2
);
echo “n1={
$n1
} n2={
$n2
}”;
?>
|
The result is: N1=1 n2=10
This section of code is the process of passing values, custom function fun parameters pass specific $n1, $n 2 value, this is easy to understand, I said before the custom function is a value, then what is the address?
12345678910 |
function fun(
$num1
,&
$num2
)
{
$num1
=100;
$num2
=1000;
}
$n1
=1;
$n2
=10;
fun(
$n1
,
$n2
);
echo “n1={
$n1
} n2={
$n2
}”;
?>
|
This code, N1 is still the value of the pass, and N2 is the address. What difference does it have? That's right.. is in the function of the parameters of a "&" take the address, meaning is to pass the memory address to the parameter, which is equal to $num2=& $n 2, the result is n3=1 n4=1000.
Alternative asset allocation rise gold ETF Link Fund intensive release: http://licai.daiyuline.com/jijin/313.html
Crude oil market dismal Exxon Mobil's first downgrade in 86 years: http://licai.daiyuline.com/yyjg/312.html
"Pass-through" and "pass-through" learning notes for PHP custom functions