Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How exactly is PHP creating superglobal $_POST, $_GET, $_COOKIE and $_REQUEST?

Tags:

People also ask

Which Superglobal variable is an array containing the contents of $_ GET $_ POST and $_ cookies?

The $_REQUEST variable provides the contents of the $_GET , $_POST , and $_COOKIE arrays.

How can we use $_ GET $_ POST $_ request variable in PHP?

How to use it? Before you can use the the $_POST variable you have to have a form in html that has the method equal to POST. Then in the php, you can use the $_POST variable to get the data that you wanted. The $_POST syntax is ($_POST['name of the form field goes here']).

What's the difference between $_ POST $_ GET and $_ request?

Now, There are total three super global variables to catch this data in PHP. $_POST : It can catch the data which is sent using POST method. $_GET : It can catch the data which is sent using GET method. $_REQUEST : It can catch the data which is sent using both POST & GET methods.

Where does the content of PHP Superglobal variable $_ GET come from?

The $_GET variable is a PHP superglobal that collects data from an HTML form after submission. The HTML form is structured in a way that $_GET is used as a method.


I'm sorry for confusing title of the question, I'll try to clarify what the issue is.

I'm doing some work with Mongrel2 server and I'm writing a PHP handler that has access to raw HTTP request data. Because I have PHP behind Mongrel2, there is no automatic creation of $_POST, $_GET, $_COOKIE and $_REQUEST variables.

The question is - is there a way that I can send the raw HTTP request to a PHP function (or anything) that will produce the superglobal variables that are usually available when using Apache + PHP?

Note: I could parse the HTTP request manually and create those variables myself, but I wasn't able to find any documentation on how exactly PHP does this HTTP parsing and importing into superglobals. If possible, I'd like to automate this process of superglobal creation without having to parse HTTP requests myself.

Thank you for any input.