GET Methods

0 adelemckean6404 December 12, 2020

This is the collection of array variables that pass through the HTTP GET methods. The $_GET variable uses to collect the value from the URL parameter. These parameters may be sent using PHP form with action GET.

Lets take an URL with parameter that we can access via HTTP GET Request.

https://codehelppro.com/detail/php/get-methods/?type=post&language=php

In the above URL, We can access the type and language parameter using HTTP GET methods as shown below.

<?php

    echo $_GET['type'];
    echo $_GET['language'];

?>

The output of the above program is

post
php

If we use form for the get methods then we can use the form as below:

<form action="" method="get">
   <input type="text" name="name" placeholder="Full Name"/>
   <input type="button" value="Submit" />
</form>

If we submit the above form then we can access the user input value using the $_GET[‘name’] variable.