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:
}
?>
$_REQUEST
$_REQUEST — Variables ie petición HTTP
Descripción
Un valor tipo array asociativo que contiene de forma predeterminada los datos de $_GET, $_POST, y $_COOKIE.
Registro de cambios
| Versión | Descripción |
|---|---|
| 5.3.0 | Se introdujo request_order. Esta directiva afecta el contenido de $_REQUEST. |
| 4.3.0 | La información de $_FILES fue retirada de $_REQUEST. |
| 4.1.0 | Se introdujo $_REQUEST. |
Notes
Note: This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods.
Note: Cuando se corre en la línea de comandos, esta variable no incluirá las entradas argv y argc; éstas se encuentran disponibles en la matriz $_SERVER.
Note: Estas son variables entregadas al script a través de los mecanismos de entrada GET, POST y COOKIE, y por lo tanto no son confiables. La presencia y el orden de la inclusión de variables en esta matriz se define de acuerdo a la directiva de configuración de PHP variables_order.
$_REQUEST
17-Jul-2008 08:04
