Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何创建仅打印 2、4、6、8 的 for 循环?
我一直在四处寻找,但找不到它。上学了哈哈!
<?php for ($x=2; $x<=8; $x+=2) { echo "The number is: $x <br>"; } ?>
for(var a = 2; a<=8;a++){ console.log(a); a = a+1;
}
这是你要找的吗?
try this for($i=1;$i<=8;$i++){ echo $i*2; if($i==8){ break; } }