Page 1 of 1

How to get HTTP request as an array?

Posted: Thu Jun 19, 2003 6:34 am
by berniecc
How to get HTTP request as an array of parametes=>values?

Thanx.
Bernie.

Posted: Thu Jun 19, 2003 7:24 am
by []InTeR[]
Request variables: $_REQUEST
Note: Introduced in 4.1.0. There is no equivalent array in earlier versions.

An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.

Note: Prior to PHP 4.3.0, $_FILES information was also included into $_REQUEST.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_REQUEST; to access it within functions or methods.

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_REQUEST array. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals

Posted: Thu Jun 19, 2003 8:27 am
by berniecc
Well, i've already read it from the help files, but the simple question is:

what code is needed to make a loop just to get every parameter id and each value?

Thanx.
Bernie.
[]InTeR[] wrote:Request variables: $_REQUEST
Note: Introduced in 4.1.0. There is no equivalent array in earlier versions.

An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.

Note: Prior to PHP 4.3.0, $_FILES information was also included into $_REQUEST.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_REQUEST; to access it within functions or methods.

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_REQUEST array. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals

Posted: Thu Jun 19, 2003 9:05 am
by twigletmac
Could you explain a bit more what you are trying to achieve. Are you looking to use something like foreach()?

Code: Select all

foreach ($_REQUEST as $key => $value) {
    echo '$key='.$key.' and value='.$value;
}
Mac

Posted: Thu Jun 19, 2003 9:36 am
by berniecc
This example is just what I needed to know.

Thank you.
Bernie.
twigletmac wrote:Could you explain a bit more what you are trying to achieve. Are you looking to use something like foreach()?

Code: Select all

foreach ($_REQUEST as $key => $value) {
    echo '$key='.$key.' and value='.$value;
}
Mac