Page 1 of 1

Form Interrogation Efficiency Question

Posted: Sun Aug 18, 2002 4:15 pm
by HUWUWA
Hi guys, I use $_POST['variable'] to collect data from a form. Now let's say I have a SELECT in my form with lots of options and I want to do an if...elseif...else on the value, for example:

$strValue="Insufficient Entry";

if($_POST['variable'] == 0){
$strValue="None Entered";
elseif($_POST['variable'] == 1){
$strValue="Selection Number 1";
}
...
...
// lots of them

Is it better to go:
$formValue=$_POST['variable'] first and then do the conditional test on $formValue ?

I'm wondering if everytime I go $_POST['variable'] it does more than just pulling a value from an existing array.

Thanks guys.

Posted: Sun Aug 18, 2002 5:44 pm
by fatalcure
it doesnt really matter, using just the $_POST['variable'] method will save more memory than assigning it to a $formValue.

You could do $formValue = &$_POST['variable'], which creates a pointer to that variable, so no extra memory is reserved for the new variable. But whenever you make a change to $formValue now will change the value in $_POST['variable'] as well.