Home > Article > Backend Development > PHP5.3 new operator goto_PHP tutorial
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"