PHP中break及continue两个流程控制指令区别分析
以下举例说明
break 用来跳出目前执行的循环,并不再继续执行循环了。
复制代码 代码如下:
$i = 0;
while ($i if ($arr[$i] == "stop") {
break;
}
$i++;
}
?>
continue 立即停止目前执行循环,并回到循环的条件判断处,继续下一个循环。
复制代码 代码如下:
while (list($key,$value) = each($arr)) {
if ($key == "zhoz"){ // 如果查询到对象的值等于zhoz,这条记录就不会显示出来了。
continue;
}
do_something ($value);
}
// 例子2
foreach ($list as $temp) {
if ($temp->value == "zhoz") {
continue; // 如果查询到对象的值等于zhoz,这条记录就不会显示出来了。
}
do_list; // 这里显示数组中的记录
}
?>
注意的是:PHP中不能使用 goto 循环指令。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft