PHP $_GET is a super global or automatic global variable. It uses to collect form data after submitting a form with the “get” method. It passes data in an associative array. Form “get” method passes an associative array of data via URL and PHP $_GET method collects those data.
So, $_GET can collect data that come via URL.
So, $_GET can populate all URL query strings (aka, URL parameter).
Some important points:-
- The GET method is restricted to sending up to 1024 characters only.
- We cannot pass any sensitive data like:- user name, password, etc. using the GET method.
- We cannot pass any binary data like images, pdf, word documents, etc. using the GET method.
- GET method can be useful in pagination, AJAX calls, etc.
Example:-
http://kshtutor.com/?name=ksh
$name = $_GET[‘name’];
echo $name;
//output:- ksh
HTML Form Example:-
<?php
if( $_GET[“animal”] || $_GET[“type”] ) {
echo “Your “. $_GET[animal]. “<br />”;
echo “Animal Type “. $_GET[type];
exit();
}
?>
<html>
<body>
<form action = “<?php $_PHP_SELF ?>” method = “GET”>
Animal : <input type = “text” name = “animal” />
Type : <input type = “text” name = “type” />
<input type = “submit” />
</form>
Read Also:-
For more detail about variables please see manual