Use if, elseif and else statements to modify the output slightly:
When the loop variable $i is 10 and until its value is down to 3, it should simply print the loop variable followed by a newline.
When the loop variable is 2, it should print "Ready!", followed by a newline.
When the loop variable is 1, it should print "Set!", followed by a newline.
When the loop variable is 0, it should print "Go!".
for($i = 10; $i >= 0; $i--){
$j = $i;
if($j > 2){
echo $j."\n";
}elseif($j = 2){
echo "Ready!\n";
}elseif($j = 1){
echo "Set!\n";
}else{
echo "Go!";
}
}
?>
输出结果为:10 9 8 7 6 5 4 3 Ready! Ready! Ready!
为什么会卡在2那里,求解原理。
Solved,
The equal sign requires double