php_joe Posted February 28, 2007 Share Posted February 28, 2007 The PHP manual says: Request variables: $_REQUEST An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE. 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 superglobals. Which is interesting, but not very helpful for me. I could really use a simple example please. Thank you. Link to comment https://forums.phpfreaks.com/topic/40479-how-do-i-use-_request-to-get-a-list-of-variables/ Share on other sites More sharing options...
btherl Posted February 28, 2007 Share Posted February 28, 2007 Try the following to investigate: var_dump($_REQUEST); print_r($_REQUEST); foreach ($_REQUEST as $name => $value) { print "$name has value $value\n"; } Then call your script with some arguments, for example http://domain.com/script.php?something=this&another=somethingelse $_REQUEST will also include posted variables and cookies, in addition to GET variables (which is what is used in the example url above) Link to comment https://forums.phpfreaks.com/topic/40479-how-do-i-use-_request-to-get-a-list-of-variables/#findComment-195862 Share on other sites More sharing options...
php_joe Posted February 28, 2007 Author Share Posted February 28, 2007 Thank you very much! Link to comment https://forums.phpfreaks.com/topic/40479-how-do-i-use-_request-to-get-a-list-of-variables/#findComment-196093 Share on other sites More sharing options...
flappy_warbucks Posted February 28, 2007 Share Posted February 28, 2007 The PHP manual says: Request variables: $_REQUEST An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE. 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 superglobals. Which is interesting, but not very helpful for me. I could really use a simple example please. Thank you. what i would do is this: <?php foreach($_REQUEST as $key => value) { echo "$key => $value<br>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/40479-how-do-i-use-_request-to-get-a-list-of-variables/#findComment-196097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.