PHP 8.4.0 RC3 available for testing

$_REQUEST

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

$_REQUESTHTTP Request-Variablen

Beschreibung

Ein assoziatives Array, das standardmäßig den Inhalt von $_GET, $_POST und $_COOKIE enthält.

Anmerkungen

Hinweis:

Dies ist eine 'Superglobale' oder automatisch globale Variable. Dies bedeutet, dass sie innerhalb des Skripts in jedem Geltungsbereich sichtbar ist. Es ist nicht nötig, sie mit global $variable bekannt zu machen, um aus Funktionen oder Methoden darauf zuzugreifen.

Hinweis:

Wenn das Skript auf der Kommandozeile ausgeführt wird, enthält die Variable nicht den Inhalt von argv und argc; diese finden sich im Array $_SERVER.

Hinweis:

Die Variablen in $_REQUEST werden dem Skript mittels der GET-, POST- und COOKIE-Inputmechanismen zur Verfügung gestellt. Daher kann der Inhalt durch einen entfernten Benutzer modifiziert worden sein und ist daher als nicht vertrauenswürdig zu betrachten. Das Vorhandensein und die Reihenfolge des Variableninhalts in diesem Array wird entsprechend der PHP-Konfigurationsdirektiven request_order und variables_order bestimmt.

add a note

User Contributed Notes 4 notes

up
194
strata_ranger at hotmail dot com
16 years ago
Don't forget, because $_REQUEST is a different variable than $_GET and $_POST, it is treated as such in PHP -- modifying $_GET or $_POST elements at runtime will not affect the ellements in $_REQUEST, nor vice versa.

e.g:

<?php

$_GET
['foo'] = 'a';
$_POST['bar'] = 'b';
var_dump($_GET); // Element 'foo' is string(1) "a"
var_dump($_POST); // Element 'bar' is string(1) "b"
var_dump($_REQUEST); // Does not contain elements 'foo' or 'bar'

?>

If you want to evaluate $_GET and $_POST variables by a single token without including $_COOKIE in the mix, use $_SERVER['REQUEST_METHOD'] to identify the method used and set up a switch block accordingly, e.g:

<?php

switch($_SERVER['REQUEST_METHOD'])
{
case
'GET': $the_request = &$_GET; break;
case
'POST': $the_request = &$_POST; break;
.
.
// Etc.
.
default:
}
?>
up
18
mike o.
14 years ago
The default php.ini on your system as of in PHP 5.3.0 may exclude cookies from $_REQUEST. The request_order ini directive specifies what goes in the $_REQUEST array; if that does not exist, then the variables_order directive does. Your distribution's php.ini may exclude cookies by default, so beware.
up
4
codeblog.pro
4 years ago
In PHP version 7.0 with the default settings.+, $_REQUEST array does not contain cookies.
up
6
Luke Madhanga
8 years ago
To access $_POST, $_GET, etc, use the function filter_input(TYPE, varname, filter) to ensure that your data is clean.

Also, I was brought up to believe that modifying superglobals is a BAD idea. I stand by this belief and would recommend you do too
To Top