php遞迴呼叫流程分析
阿新 • • 發佈:2021-02-06
<?php function loop($x, $key=false){ static $i = 0; echo $i; echo "<br>"; $i++; if($i<10){ loop($x); } else{ echo "large than 10"; echo "<br>"; } if ($key){ echo "key is true"; echo "<br>"; } else { echo "key is false"; echo "<br>"; } echo "something in loop with i= ".$i; echo "<br>"; } $x=100; loop($x, true); ?>
輸出:
0 1 2 3 4 5 6 7 8 9 large than 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is false something in loop with i= 10 key is true something in loop with i= 10