PHP: Request Method | Variable

What is the use of the Request method in PHP?

There is a simple use of the request method or request variable. You can say the $_REQUEST variable. The REQUEST variable can contain the contents of $ _GET, $ _POST, and $ _cookie.

In the previous tutorials, we discussed the GET method and the POST method in PHP. .We will discuss the cookie variable in another tutorial.

When we send the information using the POST method or GET method , we can get that information using the REQUEST variable. The REQUEST variable supports GET, POST, and cookie.

Definition of the REQUEST method

Request($_REQUEST) can access the value of the GET and POST method.

In PHP ,$_REQUEST is a superglobal variable that is used to collect the data after submitting HTML form .
The super global variable $_REQUEST contains the contents of $_GET, $_POST, and $_COOKIE.




Example of the REQUEST method

In the below example, we create an HTML form. When a user fills the information and clicks on the submit button, the information contains by the REQUEST variable.

In the HTML form, we create two fields. In the HTML form, we use the GET method. The GET method encodes the information and sends it to the server. The encoded information separated by the? mark with the page.

We can use the REQUEST method to contains all information of the GET method. Let's create an example.


<form action="" method="GET">


echo $name;
echo $name;

In this above example, we have created two fields. Whatever information comes in both fields, the GET method handles that information of text boxes. With the help of the REQUEST variable, we have displayed the values of the GET method.

The $_REQUEST variable, you can use to get the result form data sent with both the GET and POST method.

Please Share

Recommended Posts:-