Reputation: 1
I was searching where to use $_POST
, $_REQUEST
, $_GET
but I only saw the differences among them.
The only I got to know that
$_REQUEST
contains remaining two.$_GET
is used for fetching.$_POST
is used for inserting, updating, deleting.I want to know these things
I want to know that when $_REQUEST
can perform all the tasks then why there was need to create remaining two.
Explain the situations where we choose either $_REQUEST
and where we choose
$_GET
or $_POST
and not $_REQUEST
And what will the loss if we use use $_REQUEST
instead of $_GET
or $_POST
Upvotes: 0
Views: 31
Reputation: 616
If it doesn't matter to you wether data comes in via post or via get you can use $_REQUEST. If you know which of the two will be the method data will be provided to your server-side code, use the appropriate super global. E.g. it's extremely easy to tamper with GET parameters, so you might want to avoid this method in certain parts of your application for security reasons. If you use POST you shouldn't read $_REQUEST, because there's a risk someone might add additional parameters in the URL via GET.
Upvotes: 1