search
Homephp教程php手册PHP中break及continue两个流程控制指令区别分析

PHP中break及continue两个流程控制指令区别分析

Jun 13, 2016 pm 12:10 PM
breakcontinuephpanalyzethe differenceinstructioncontrolprocessJump out

以下举例说明
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 循环指令。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.