All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
PHP编程中break及continue两个流程控制指令_php资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/24 5:51:04 Browse times: 483 Comment times: 0

PHP编程中break及continue两个流程控制指令_php资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

PHP编程中break及continue两个流程控制指令_php资料_编程技术-你的首页-uuhomepage.com

讲解一下PHP脚本编程中 break 及 continue 两个流程控制指令。

break 用来跳出目前执行的循环,如下例

$i = 0;
while ($i < 10) {
if ($arr[$i] == "stop") {
break;
}
$i++;
}
?>

----------------------------------------------

continue 立即停止目前执行循环,并回到循环的条件判断处,见下例

while (list($key,$value) = each($arr)) {
if ($key % 2) { // 略过偶数
continue;
}
do_something_odd ($value);
}
?>

而 basic 常用的 goto 在 c 及 borland pascal 中或许可以使用。但在 php 中,由于它的 web server script 特性以及结构化的组成,并不能在 php 中使用 goto 循环指令?






There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.