php定义的默认参数“
function student1($name, $num=01){
echo "amount=$name
";
echo "num=$num
";
}
function student2($name=Li,$num){
echo "amount=$name
";
echo "num=$num
";
}
student1(L);
student2(02);
student2(liu,03)
?>
结果
函数返回值:
function calculate_area($height,$width){
$area=$height*$width;
return $area;
}
$total=calculate_area(4,3);
echo $total
?>
结果:
function results(){ //声明函数
$fruit=array("apple", //声明数组
"banana",
"orange");
return $fruit; //返回
}
//调用函数
$a = results();
print_r($a); //输出数组,多返回值
?>