Page 1 of 1
Just out of curiosity
Posted: Sat Jan 27, 2007 11:06 am
by superdezign
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?
Posted: Sat Jan 27, 2007 11:49 am
by nickvd
$HTTP_POST_VARS is depreciated, and I do believe that it has been turned off by default on php5, and will be removed as of php6
Posted: Sat Jan 27, 2007 11:53 am
by volka
And $HTTP_POST_VARS is a normal array in global space while $_POST is a so-called superglobal array.
Code: Select all
function foo() {
global $HTTP_POST_VARS;
echo count($HTTP_POST_VARS);
}
// but
function bar() {
echo count($_POST);
}
Using $_GET but $HTTP_POST_VARS is inconsistent and on a code review I would even mark it as error.
Posted: Sat Jan 27, 2007 12:02 pm
by superdezign
Okay, thanks. The reason I started using it was 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_VARS
Thanks for the enlightenment.
Posted: Sat Jan 27, 2007 12:12 pm
by volka
And what error do you get?
Posted: Sat Jan 27, 2007 12:21 pm
by superdezign
Hmm? Oh I'm not getting any errors. I just had a feeling that I shouldn't be using $HTTP_POST_VARS. I guess I was right.
Posted: Sat Jan 27, 2007 12:59 pm
by volka
error
superdezign 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_VARS
or no error
superdezign wrote:Oh I'm not getting any errors.
that is the question...
Posted: Sat Jan 27, 2007 1:32 pm
by louie35
try adding the @ before the $_POST[''] like this
or at least check to see if is set like this:
Code: Select all
if(isset($_POST['string'])){
...
}
Posted: Sat Jan 27, 2007 2:02 pm
by onion2k
louie35 wrote:try adding the @ before the $_POST[''] like this
Never, ever, ever do that. Fix the problem, don't just hide it.
Posted: Sat Jan 27, 2007 2:57 pm
by feyd
onion2k wrote:Never, ever, ever do that. Fix the problem, don't just hide it.
Indeed.
Posted: Sat Jan 27, 2007 3:02 pm
by superdezign
volka wrote:error
superdezign 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_VARS
or no error
superdezign wrote:Oh I'm not getting any errors.
that is the question...
No no.. nobody is understanding me
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