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 More infoAdvertise with us Next Article PHP goto Statement V vkash8574 Follow Improve Article Tags : Web Technologies PHP PHP-basics Similar Reads PHP continue Statement The continue statement is used within a loop structure to skip the loop iteration and continue execution at the beginning of condition execution. It is mainly used to skip the current iteration and check for the next condition. The continue accepts an optional numeric value that tells how many loops 1 min read PHP switch Statement The switch statement is similar to the series of if-else statements. The switch statement performs in various cases i.e. it has various cases to which it matches the condition and appropriately executes a particular case block. It first evaluates an expression and then compares it with the values of 2 min read Getting Started with PHP PHP (Hypertext Preprocessor) is a powerful scripting language widely used for web development. Whether you're looking to create dynamic web pages, handle form data, interact with databases, or build web applications, PHP has you covered. In this guide, we'll take you through the basics of PHP, cover 7 min read PHP | ob_start() Function Let's take a quick recap. PHP is an interpreted language thus each statement is executed one after another, therefore PHP tends to send HTML to browsers in chunks thus reducing performance. Using output buffering the generated HTML gets stored in a buffer or a string variable and is sent to the buff 2 min read PHP | $ vs $$ operator The $ operator in PHP is used to declare a variable. In PHP, a variable starts with the $ sign followed by the name of the variable. For example, below is a string variable: $var_name = "Hello World!"; The $var_name is a normal variable used to store a value. It can store any value like integer, flo 2 min read Like