Since PHP was built with web development as a primary use case, it has functionality to ease processing of HTML requests. When the front end client makes a request to a backend PHP server, several superglobals related to the request are available to the PHP script. Superglobals are automatic global variables which are available in all scopes throughout a script.
The list of superglobals in PHP includes the following:
For this lesson, we are focusing on three of these:
$_GET- this contains an associative array of variables passed to the current script using query parameters in the URL
$_POST- this contains an associative array of variables passed to the current script using a form submitted using the “POST” method
$_REQUEST- this contains the contents of
In the code, we’ve set up two HTML forms, one using the “GET” method and one using the “POST” method.
Print the values of the
$_POST superglobals after their corresponding text in the HTML using the built-in
Try typing some words into each of the forms and submitting them to examine the behavior of these superglobals. Use the “reset” button to reset the form.
When does the URL in the demo browser change?