VOOZH about

URL: https://www.geeksforgeeks.org/php/php-goto-statement/

⇱ PHP goto Statement - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP goto Statement

Last Updated : 22 Aug, 2022

The goto statement is used to jump to another section of a program. It is sometimes referred to as an unconditional jump statement. The goto statement can be used to jump from anywhere to anywhere within a function.

Flowchart of goto statement:

👁 Image
 

Syntax:

statement_1;

if (expr)
 goto label;
statement_2;
statement_3;

label: statement_4;

Example 1: The following code demonstrates the goto statement.


Output
26 is even

Example 2: This is another code to demonstrate the goto statement of PHP.


Output
1 2 3 4 5 6 7 8 9 10 

Reference: https://www.php.net/manual/en/control-structures.goto.php

Comment
Article Tags: