倒序数字出现问题

【字号: 日期:2024-04-23浏览:122作者:雯心

问题描述

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!".

<?php

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那里,求解原理。

问题解答

回答1:

已解决,

等号需要双个

相关文章: