Extract all variables sent with POST , GET or PUT?
I am tired of extracting each variable posted by the FORM. weather its a $_GET or $_POST or $_PUT. I always wondered How can I extract all variables from request, especially $_POST?
Normally, I do
to see the contents in the $_POST variable. then extract them each one line at a time. which is , in some cases a big waste of time.
Easiest Method I found was very easy:
his code answers his question perfectly “How do I get all variables sent with POST?”. If security may not be an issue for your project, those who made php invented this function, so that it should be used. but carefully.
In production systems its never a good idea to extract all POST variables.
Another approach can be
$getArray = ($tmp = filter_input_array(INPUT_GET)) ? $tmp : Array();
$postArray = ($tmp = filter_input_array(INPUT_POST)) ? $tmp : Array();
$allRequests = array_merge($getArray, $postArray);
But then you will have to loop thru the output and that will bring us back to original problem.
I have seen people doing
I am not sure why do they use @ , any thoughts?
How extract all variables from the superglobal arrays $_GET and $_POST can be transferred into normal variables?
If the register_globals setting has been deactivated (which should be the case), the GET and POST parameters can only be accessed via the superglobals of the same name ($_GET, $_POST). As soon as register_globals is switched on, however, a variable with the same name is created for each parameter. When calling up http://www.example.com/index.php?name=Alex&age=25, for example, the variables “name” (with value “Alex”) and “age” (with value “25”) would be generated fully automatically. To simulate this behavior, the function extract() can be used on $_GET and / or $_POST. The function reads all key-value pairs and creates variables with the key as name and the value as variable content. Excrept from a blog