Home  >  Article  >  Backend Development  >  PHP5.3 new operator goto_PHP tutorial

PHP5.3 new operator goto_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:45:38833browse

goto
The goto operator can be used to jump to a specified location in the program. The target location can be marked with the target name followed by a colon. Goto in PHP has certain restrictions and can only jump within the same file and scope. This means that you cannot jump out of a function or class method, nor can you jump into another function. You also cannot jump into any loops or switch structures. Common usage is to break out of a loop or switch, which can replace multiple levels of break.
eg.
goto a;
echo 'Foo';

a:
echo 'Bar';
?> //bar
Note:
The goto operator is only available in PHP 5.3 and above.

Author "My PHP Road"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478651.htmlTechArticlegoto The goto operator can be used to jump to a specified location in the program. The target location can be marked with the target name followed by a colon. Goto in PHP has certain restrictions, it can only be used in the same document...
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