Home  >  Article  >  Backend Development  >  php exit、return、break、continue之间的区别,详细介绍

php exit、return、break、continue之间的区别,详细介绍

WBOY
WBOYOriginal
2016-06-23 13:47:021005browse

相信大家在php开发中有几个常用的停止程序和循环的关键字的误区( exit、return、break、continue)


exit 退出所有脚本,是个函数



return 语言结构的用法---作用:终止函数的执行和从函数中返回一个值


break 结束当前 for,foreach,while,do..while 或者 switch 结构的执行(break 可以接受一个可选的数字参数来决定跳出几重循环)


continue 在循环结构中用来跳过本次循环中剩余的代码并开始执行本循环结构的下一次循环。( 接受一个可选的数字参数来跳过几重循环到循环结尾。)
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