阅读PHP书时,我想尝试自己的(继续)示例。 我作了如下的代码,但它不工作,尽管一切都似乎是确定PHP继续声明
$num2 = 1;
while ($num2 < 19)
{
if ($num2 == 15) {
continue;
} else {
echo "Continue at 15 (".$num2.").<br />";
$num2++;
}
}
输出是
Continue at 15 (1).
Continue at 15 (2).
Continue at 15 (3).
Continue at 15 (4).
Continue at 15 (5).
Continue at 15 (6).
Continue at 15 (7).
Continue at 15 (8).
Continue at 15 (9).
Continue at 15 (10).
Continue at 15 (11).
Continue at 15 (12).
Continue at 15 (13).
Continue at 15 (14).
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/php/continueandbreak.php on line 20
第20行是该行
if ($num2 == 15) {
好了好了告诉我我的例子有什么问题? 对于这样一个Noob问题,我很抱歉
你的代码仍然可以无限循环; 'continue'开始循环的下一次迭代,而不执行if-else子句后面的内容。 – Amber 2009-11-13 03:02:22
哇,令人尴尬 – 2009-11-13 03:02:51
感谢很多,这工作很好,我有这个想法。 – taabouzeid 2009-11-13 03:25:50