April 2026
Intermediate
1009 pages
34h 15m
English
Jumps in the code flow is a function that is not used very often in PHP. The goto operator was introduced in PHP 5.3 and is very easy to use: You insert a marker. The name is freely selectable and is supplemented with a colon. You then call the tag with goto tag name. All code in between is skipped. In the following example, output 1 is ignored, and then output 2 is displayed (see Figure 5.30).
<?php goto marker; echo 'output 1'; marker: echo 'output 2'; ?>
Listing 5.37 A Jump via "goto" ("goto.php")
Figure 5.30 Only the Second Edition Is Visible.
goto does not allow a jump to a loop or switch case differentiation. ...
Read now
Unlock full access