The goto operator can be used to jump to another position in the program. The target location can be marked by the target name with a colon, while the jump command is the tag of the target location after the goto. PHP has certain restrictions on goto. the target location can only be in the same file and scope, and the goto operator can be used to jump to another position in the program. The target location can be marked by the target name with a colon, while the jump command is the tag of the target location after the goto. The goto in PHP has certain restrictions. the target location can only be in the same file and scope. that is to say, you cannot jump out of one function or class method, or jump into another function. And cannot jump into any loop or switch structure. You can jump out of a loop or switch. Generally, you can use goto to replace multiple levels of break.
Example #1 goto Example
The above routine will output:
Bar
Example #2 Example of a goto bounce loop
The above routine will output:
J hit 17
Example #3 the following statement is invalid
The above routine will output:
Fatal error: 'Goto 'into loop or switch statement is disallowed in
Script on line 2
Note:
The goto operator is only valid in PHP 5.3 and later versions.