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