if($a>100){
return $a;
}
$a++;
test($a);
}
echo test(1); ##這樣可能並不會返回101,無法輸出或得到相應的結果
改成
function test($a){
if($a>100){
return $a;
}
$a++;
return test($a); ///加上return 則可以正常返回值了
}
echo test(1);
echo test(1); ##這樣可能並不會返回101,無法輸出或得到相應的結果
改成
function test($a){
if($a>100){
return $a;
}
$a++;
return test($a); ///加上return 則可以正常返回值了
}
echo test(1);