GET is the method used by the browser to request normal web pages, but it can also be used to submit form data. Type a search term in to Google and hit search – notice how the results page has your query encoded in to the URL shown in your browser’s task bar.
GET is ideal for applications like search engines where is useful to bookmark the resulting page. You will be able to do it as the browser will append a query string (a string made of key-value couples) to the URL.
GET is limited in that it can only handle small amounts of data.
Variables sent to a PHP script using the GET method are made available to your program as items in the $_GET global array. For example, data from a text field <input type=”text” name=”firstname”> sent using GET will be available to your program as $_GET[‘firstname’] .
From a query string like:
www.myscript.php?name=john&surname=doe
you will be able to fetch parameters printing the $_GET array
1 |
<?php echo "<pre>";<br> print_r($_GET);<br> echo "</pre>";<br> /* this will be the content of $_GET<br> Array ( [name] => john [surname] => doe )<br> */ ?> |