Just out of curiosity
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Just out of curiosity
I'm almost done my first E-commerce website and I just got to thinking...
I've got into this habit, not sure if it's valid or not, of using $HTTP_POST_VARS instead of $_POST, but I still use $_GET.
Is there any difference between $HTTP_POST_VARS and $_POST in php?
I've got into this habit, not sure if it's valid or not, of using $HTTP_POST_VARS instead of $_POST, but I still use $_GET.
Is there any difference between $HTTP_POST_VARS and $_POST in php?
And $HTTP_POST_VARS is a normal array in global space while $_POST is a so-called superglobal array.
Using $_GET but $HTTP_POST_VARS is inconsistent and on a code review I would even mark it as error.
Code: Select all
function foo() {
global $HTTP_POST_VARS;
echo count($HTTP_POST_VARS);
}
// but
function bar() {
echo count($_POST);
}- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
try adding the @ before the $_POST[''] like this
or at least check to see if is set like this:
Code: Select all
@$_POST['string']Code: Select all
if(isset($_POST['string'])){
...
}Never, ever, ever do that. Fix the problem, don't just hide it.louie35 wrote:try adding the @ before the $_POST[''] like this
Code: Select all
@$_POST['string']
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
No no.. nobody is understanding mevolka wrote:erroror no errorsuperdezign wrote:because I got an error from $_POST, but I'm sure I meant to change it back to $_POST after getting the same error with $HTTP_POST_VARSthat is the question...superdezign wrote:Oh I'm not getting any errors.
I mean once, a long time ago, I had an error and was using $_POST, and tried using $HTTP_POST_VARS after looking at something I googled, but I also changed the surrounding code
Just somehow, something in my mind made me think the error had something to do with the fact that I used $_POST, but I just looked at it again and the problem was earlier on in the code. It's been fixed though.
This topic was just a question as to the difference between the two.
No errors. Sorry if I confused anyone :-p