PHP goto operator
Can be used to jump to another location in the program. The position can be marked with the target name plus a colon, and the jump instruction is the position marker that the target is connected to after Goto
Some restrictions on the use of goto operators
The target location can only be in the same file and scope
Cannot "jump out" a function and a method of a class
Cannot "jump in" to another function
Cannot "jump" into any loop or switch structure
Can "jump out" the loop or switch, the general usage is to replace the multi-layer break
Simple and practical case
Goto target;
Echo ' Hi world ';
Target:
echo ' Hello World ';
Result Hello World
$i = 0;
$j = 50;
for ($i < 100; $i + +) {
while ($j-) {
if ($j = = 17)
Goto end;
}
}
echo "i = $i";
End:
Echo ' J hit 17 ';
Result J hit 17
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/A5/wKiom1Xp1g-yRk2bAAE_3WRhoUQ131.jpg "title=" capture. PNG "alt=" Wkiom1xp1g-yrk2baae_3wrhouq131.jpg "/>
This article is from the "Ouyangjun" blog, make sure to keep this source http://ouyangjun.blog.51cto.com/10284323/1691585
PHP goto operator