Tags
Asked 3 years ago
10 Aug 2021
Views 209
Lisa

Lisa posted

What is $_ GET ?

What is $_ GET ?
ravi

ravi
answered Aug 17 '21 00:00


$_GET is used to get the value of the HTML get method in PHP .
$_GET is the array of the query string in PHP.
suppose we surf URL :

https://www.ecom.com/product-detail.php?id=3052&action=show

after the question mark(?), all in the URL is the query string which we can get at PHP side by $_GET

echo $_GET['id'];
echo $_GET['action'];


it will print 305 and show for above url

by HTML form element , sending get method request as below

<form method="get" action="product-detail.php">
<input type="hidden" name="id" value="305"/>
<input type="hidden" name="action" value="show"/>
</form>


here method="get" means HTML form element method gets and on submit , it send get query string to PHP .
and we can get query string as we did previously by $_GET

echo $_GET['id'];
echo $_GET['action'];

If you don't provide any method to get or post to HTML form element, then it takes the default method as get
Post Answer