php 中 return exit break contiue 详解_第1页
免费预览已结束,剩余3页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、php 中 return exit break contiue 详解作用:output a message and terminate the current script输出一则消息并且终止当前脚本。假如一段文本中包括多个以 结束的脚本,exit退出全部脚本。比如一篇php文本包括一下代码,则不输出为world。echo hello;exit;?echo world;?复制代码语法格式:void表示没有返回值。void exit ( string $status )void exit ( int $status )if status is a string, this function pr

2、ints the status just before exiting.假如status是一段字符串,这个函数在脚本退出前打印status。if status is an integer, that value will also be used as the exit status. exit statuses should be in the range 0 to 254, the exit status 255 is reserved by php and shall not be used. the status 0 is used to terminate the program s

3、uccessfully.假如status是一个整数,这个整数会被作为退出状态。退出状态应当从0到254,退出状态255被php保留并禁止用法。状态0被用来表示胜利的终止程序。2.return语言结构的使用作用:终止函数的执行和从函数中返回一个值3.break和continue用在for,foreach,while,do.while 或者 switch 结构中。break 结束当前 for,foreach,while,do.while 或者 switch 结构的执行。break 可以接受一个可选的数字参数来打算跳出几重循环。代码:$arr = array (one, two, three, fo

4、ur, stop, five);while (list (, $val) = each ($arr) if ($val = stop) break;echo $valn; $i = 0;while (+$i) switch ($i) case 5:echo at 5n;break 1;case 10:echo at 10; quittingn;break 2;default:break;?复制代码continue 在循环结构用用来跳过本次循环中剩余的代码并开头执行本循环结构的下一次循环。注: 注重在 php 中 switch 语句被认为是作为 continue 目的的循环结构。continue

5、 接受一个可选的数字参数来打算跳过几重循环到循环结尾。代码:while (list ($key, $value) = each ($arr) if (!($key % 2) / skip odd memberscontinue;do_something_odd ($value); $i = 0;while ($i+ echo outern;while (1) echo middlen;while (1) echo innern;continue 3;echo this never gets output.n;echo neither does this.n;?复制代码以上是本文关于php 中 return exit break contiue 的详解

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论