Form Interrogation Efficiency Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HUWUWA
Forum Commoner
Posts: 35
Joined: Sat Aug 17, 2002 7:24 pm
Location: Long Island, NY

Form Interrogation Efficiency Question

Post 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.
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post 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.
Post Reply