PHP $_GET superglobal

PHP $_GET
  • PHP $_GET is a PHP variable which is used to collect form data after submitting an HTML form with method="get", $_GET can also collect data sent in the URL.
  • example


  • <?php
    if( $_GET["name"] ) {
    echo "Welcome ". $_GET['name']. "<br>";
    exit();
    }
    ?>
    <html>
    <body>
    <form action = "<?php $_PHP_SELF ?>" method = "GET">
    Name: <input type = "text" name = "name" />
    <input type = "submit" />
    </form>
    </body>
    </html>

    Output:

    Welcome amit