研究php中break,continue,exit的应用与区别

WBOY
Release: 2016-06-13 10:59:59
Original
915 people have browsed it

研究php中break,continue,exit的使用与区别

1.break跳出代码片段,结束循环2.continue结束当前片段,继续下一次循环3.exit 结束整个PHP代码<?php /* php的break,continue,return 的简单区别代码 */  $i = 1;   while (true) { // 这里看上去这个循环会一直执行       if ($i==2) {// 2跳过不显示           $i++;           continue;       } else if ($i==5) {// 但到这里$i=5就跳出循循环了           break;       } else {           echo $i . '<br>';       }       $i++;   }   exit;     echo '这里不输出';   
Copy after login
?

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!