PHP goto Statement Last Updated : 22 Aug, 2022 Comments Improve Suggest changes Like Article Like Report 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: Syntax: statement_1; if (expr) goto label; statement_2; statement_3; label: statement_4; Example 1: The following code demonstrates the goto statement. PHP <?php // Function to check even or not function checkEvenOrNot($num) { if ($num % 2 == 0) // Jump to even goto even; else // Jump to odd goto odd; even: echo $num . " is even"; // Return if even return; odd: echo $num . " is odd"; } $num = 26; checkEvenOrNot($num); ?> Output26 is even Example 2: This is another code to demonstrate the goto statement of PHP. PHP <?php // Function to print numbers // from 1 to 10 function printNumbers() { $n = 1; label: echo $n . ' '; $n++; if ($n <= 10) goto label; } printNumbers(); ?> Output1 2 3 4 5 6 7 8 9 10 Reference: https://www.php.net/manual/en/control-structures.goto.php Comment V vkash8574 Follow Improve V vkash8574 Follow Improve Article Tags : Web Technologies PHP PHP-basics Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like