Hello, I have looked, but haven't been able to find a coherent answer on my question anywhere, so I ask ik here, in the hope any of you know an answer to my question.
Here it goes,
I know there is the $_GET and the $_POST vars to get the values... my question is, is there a global var that includes the values from both $_GET and $_POST? because my website has $_POST and $_GET variables to access several pages on the same way, and I'd hate to have to double code all the if statements.
Already thanks for your time,
Michael
Question about GET and POST vars...
Moderator: General Moderators
Never mind, I've built my own solution, thanks anyways if you've thought about it.
Michael
Michael
Code: Select all
function getvar($name)
{
if(IsSet($_GETї$name]))
{
$ret = $_GETї$name];
}
if(IsSet($_POSTї$name]))
{
$ret = $_POSTї$name];
}
return $ret;
}mmm, thanks, I thought of another way though... delved a bit into the phpbb code to figure out hehe.
Then I have everything I need in one.
Thanks for your help anyways.
Michael
Code: Select all
$_VAR = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);Thanks for your help anyways.
Michael
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Hmm... you don't seem to understand exactly how superglobals work...
http://us2.php.net/manual/en/language.v ... perglobals
Your code should be:
But I don't think it does exactly what you want it to (once again, read the link above)
Once again, $_REQUEST is the same as merging GET POST and COOKIE but without the overhead of calling a function, so it's faster.
Just because it works doesn't mean it's the best solution.
http://us2.php.net/manual/en/language.v ... perglobals
Your code should be:
Code: Select all
$_VAR = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_SESSION, $_ENV, $_FILES);Once again, $_REQUEST is the same as merging GET POST and COOKIE but without the overhead of calling a function, so it's faster.
Just because it works doesn't mean it's the best solution.