Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

$_REQUEST on $_GET Requests

GET requests can involve form submissions, as shown in the example above, with the method attribute of the HTML <form> element set to GET.

They can also retrieve data from a query string (information appended to a URL).

Here’s an example of how an HTML hyperlink with a query string might look:

HTML link

<html>
<body>
<a href="demo_phpfile.php?subject=PHP&web=W3schools.com">Test $GET</a>
</body>
</html>

When a user clicks the link, the query string data is sent to demo_phpfile.php.

In the PHP file, we can use the $_REQUEST variable to retrieve the values from the query string.

Example

The PHP file demo_phpfile.php:

<html>
<body>
<?php
echo "Study " . $_REQUEST['subject'] . " at " . $_REQUEST['web'];
?>
</body>
</html>