happy cat image

Start Web Coding

Your First step toward web coding,
Start Web Coding

change UI

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

강좌로 돌아가기