PHP $_GET function is sued for collection the values passed from a “form using get method”.There are two types of methods are available for a form to send data. They are “get method” and “post method”. $_GET function is applicable for get method only.
When we use get method, passed variables and its values will be displayed in browser address bar and visible for everyone.

Here is sample form using get method

<form action="form.php" method="get">
Name: <input type="text" name="yourname" />
Age: <input type="text" name="age" />
<input type="submit" value="SUBMIT FORM" />
</form>

Here you can see that values are passed to form.php using get method.
Now look at the form.php code with $_GET function

<?php
$name=$_GET["yourname"];
$age=$_GET["age"];
echo "Name :".$name."<br>";
echo "age".$age;
?>

Suppose user has entered the values JOHN for name and 25 for age in the first form. After pressing the submit button, form will send the data to form.php . That time address bar will look like
form.php?yourname=JOHN&age=25
In form.php passed values are retrieved using $_GET function and output will be like:
Name : JOHN
age : 25

Limitations of GET method :

  • Maximum characters can be passed, so its not suitable for sending large data
  • passed data will be visible in browser, so in some cases it wont be suitable to use get method like passing password and other secret datas.

Advantages of GET method :

  • User can bookmark or direct access to the page with passed data. Next time he don’t need to enter the form again to access the same page
  • Search engines can index the page with passed data. SEO friendly method