How to get HTTP request as an array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
berniecc
Forum Newbie
Posts: 5
Joined: Thu Jun 19, 2003 5:38 am
Contact:

How to get HTTP request as an array?

Post by berniecc »

How to get HTTP request as an array of parametes=>values?

Thanx.
Bernie.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post 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
berniecc
Forum Newbie
Posts: 5
Joined: Thu Jun 19, 2003 5:38 am
Contact:

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
berniecc
Forum Newbie
Posts: 5
Joined: Thu Jun 19, 2003 5:38 am
Contact:

Post 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
Post Reply