Home >php教程 >php手册 >PHP5.3新增操作符之goto

PHP5.3新增操作符之goto

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 10:44:121224browse

goto
goto操作符可以用来跳转到程序中的某一指定位置。该目标位置可以用目标名称加上冒号来标记。PHP中的goto有一定限制,只能在同一个文件和作用域中跳转,也就是说你无法跳出一个函数或类方法,也无法跳入到另一个函数。你也无法跳入到任何循环或者switch 结构中。常见的用法是用来跳出循环或者switch,可以代替多层的break。
eg。
goto a;
echo 'Foo';
 
a:
echo 'Bar';
?> //bar
Note:
The goto 操作符仅在 PHP 5.3及以上版本有效.
 
作者“我的PHP之路”

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