happy cat image

everdevel

coding

login
NotificationX
  • Currently, only notices of comments are displayed.
  • no comment or please login

goto statement

This time, let's look at the goto statement.
The goto statement allows you to skip code.
there for example 1,2,3,4,5,6,7,8,9 length so I gadaga cross towards three two to cross the first I met goto 8 code.
Then you go straight to 8 without going through 4, 5, 6, 7.

How To Use goto

goto label(where to go);

label:

Label specifies the value you want.
I don't know how to use the above
Let's look at an example.

echo "everdevel step 1 <br>";
echo "everdevel step 2 <br>";
goto goSeven;
echo "everdevel step 3 <br>";
echo "everdevel step 4 <br>";
echo "everdevel step 5 <br>";
echo "everdevel step 6 <br>";
goSeven:
echo "everdevel step 7 <br>";
echo "everdevel step 8 <br>";
echo "everdevel step 9 <br>";

If you execute the above code, the output will be output till everdevel step 2, then goto goSeven statement, go to goSeven, and output from everdevel step 7.
So let's run the code

<?php
    echo "everdevel step 1 <br>";
    echo "everdevel step 2 <br>";
    goto go7;
    echo "everdevel step 3 <br>";
    echo "everdevel step 4 <br>";
    echo "everdevel step 5 <br>";
    echo "everdevel step 6 <br>";
    go7:
    echo "everdevel step 7 <br>";
    echo "everdevel step 8 <br>";
    echo "everdevel step 9 <br>";
?>

Execution result of the code above


Thank you for visiting. If you have any inquiry or explanation of mistakes, please use the comments below.


    
    

Back to the course

ALL COMMENTS 0

Sort by