<?phpfunction draw($total,$line=1,$result="a1"){ echo "<script>alert('$total,$line')</script>"; if($line>$total){ return; } else{ $line++; //echo $result; echo "<script>alert('draw1($total,$line,$result)')</script>"; draw($total,$line,$result); echo "<script>alert('draw2($total,$line,$result)')</script>"; } echo $result;}draw(3);?>
彼は変わっていないので理由はありません
function draw($total,$line=1,$result="a1"){ echo "<script>alert('$total,$line')</script>"; if($line>$total){ return; } else{ $line++; //echo $result; echo "<script>alert('draw1($total,$line,$result)')</script>";echo "递归前 line = $line\n"; draw($total,$line,$result);echo "递归后 line = $line\n"; echo "<script>alert('draw2($total,$line,$result)')</script>"; } echo $result;}draw(3);
ありがとうございます。再帰の原理はまだ理解できていないと思うので、詳しく調べてみます