Why can _ GET get a _ POST request?

$_ GET gets the data requested by get
$_ POST gets the data requested by post

the following example

<html>
    <body>
    <?
        $flag = $_GET["flag"];
        if($flag=="1")
            echo "".$_POST["user"]."";
        else
            echo  " 
            <form action="?flag=1" method="post">
                :<input type="text" name="user" size=15>
                <input type="submit" value="submit">
            </form>";
    ?>
</body>
</html>

the first time to open this page is a form
fill in the name, click submit, using the post method, why can $_ GET ["flag"] get the value of flag?

I don"t quite understand how it works.
is the data here transmitted in post or get mode? Or have you passed it both ways?

Php
Apr.05,2021
The key point of

is that such url "? flag=1" is used in post. The result is that flag is passed to the background as a get parameter, so the background can fetch both the flag in the $_ GET parameter and the other form parameters in the $_ POST parameter.

Menu