PHP Function参数传递

按照值传递,按照引用传递
按照值传递:将变量值复制一份传到函数,函数体执行,不会对预先定义的变量值进行修改;
 
按照引用传递:将变量值直接传入函数,函数体执行改变变量预先定义的值
 
/**
 * test1是按照值传递
 */
function test1($num)
{
    $num ++;
    echo $num;
}
 
$int_b = 10;
test1($int_b);
echo "<br />";
echo $int_b;
 
/**
 * test2是按照引用传递
 */
function test2(&$num)
{
    $num ++;
    echo $num;
}
 
echo "<br />";
echo "<br />";
 
$int_b = 10;
test2($int_b);
echo "<br />";
echo $int_b;
 
 
原文地址:https://www.cnblogs.com/meroselove/p/5275326.html