Page 1 of 1

What's difference between $_REQUEST and $_POST ?

Posted: Sat Jul 19, 2008 5:42 pm
by Mds
Hi there.
What's difference between $_REQUEST and $_POST ?
And which of them is better to using ?

Thank you.

Re: What's difference between $_REQUEST and $_POST ?

Posted: Sat Jul 19, 2008 5:54 pm
by Dynamis
Mds wrote: What's difference between $_REQUEST and $_POST ?
"The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods."

W3Schools

Re: What's difference between $_REQUEST and $_POST ?

Posted: Sat Jul 19, 2008 7:16 pm
by Mds
Thank you.
I want to get POST data by my PHP's page.
Is it better to use $_REQUEST or $_POST ? :?

Re: What's difference between $_REQUEST and $_POST ?

Posted: Sat Jul 19, 2008 7:19 pm
by shiznatix
it is much better practice to use the specific superglobal instead of $_REQUEST. This way you know for sure were your variables are coming from and you won't have any collisions. Plus it makes it clearer when looking back at old code where you are getting your variables. So, in your case, use $_POST.

Re: What's difference between $_REQUEST and $_POST ?

Posted: Sat Jul 19, 2008 7:34 pm
by Dynamis
shiznatix wrote:it is much better practice to use the specific superglobal instead of $_REQUEST. This way you know for sure were your variables are coming from and you won't have any collisions. Plus it makes it clearer when looking back at old code where you are getting your variables. So, in your case, use $_POST.
I agree.

Re: What's difference between $_REQUEST and $_POST ?

Posted: Sun Jul 20, 2008 5:10 pm
by Mds
OK, I got it :wink:
Thanks guys.