Re: [PHP] if/elseif/else v. switch

2004-06-05 Thread Curt Zirzow
* Thus wrote Dennis Seavers ([EMAIL PROTECTED]):
 Is there any noticeable difference (on the part of the client)
 ...

The only time the client will perhaps notice a difference is if
your condition is in a loop that cycles a couple thousand times or
more.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] if/elseif/else v. switch

2004-06-04 Thread Dennis Seavers
Is there any noticeable difference (on the part of the client) between identical 
conditionals, one written as a switch, the other written as an if, elseif ... else 
conditional?  I realize that one programmer coming in behind another might prefer the 
gentler layout of a switch; but would there be any perceivable difference, 
client-side, between the options?

[PHP] if elseif else

2002-04-19 Thread Gerard Samuel

I redoing some code, and the original author has code like

if
elseif
elseif
elseif
else

I have always known it to have just one elseif, not multiple ones.
I was going to move it to a switch/case, but there is no common switch.
So I wanted to know if its technically ok, or just ok to use multiple elseif

Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] if elseif else

2002-04-19 Thread Leotta, Natalie (NCI/IMS)

You can use as many elseifs as you need.  I'm not sure how it affects
performance, but it works (I have one that goes through all 50 states).

-Natalie

-Original Message-
From: Gerard Samuel [mailto:[EMAIL PROTECTED]] 
Sent: Friday, April 19, 2002 10:02 AM
To: PHP
Subject: [PHP] if elseif else


I redoing some code, and the original author has code like

if
elseif
elseif
elseif
else

I have always known it to have just one elseif, not multiple ones. I was
going to move it to a switch/case, but there is no common switch. So I
wanted to know if its technically ok, or just ok to use multiple elseif

Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] if elseif else

2002-04-19 Thread The_RadiX

Nope..

That is fine..


I use it all the time.. It's quite acceptable..




- Original Message -
From: Gerard Samuel [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Saturday, April 20, 2002 12:01 AM
Subject: [PHP] if elseif else


 I redoing some code, and the original author has code like

 if
 elseif
 elseif
 elseif
 else

 I have always known it to have just one elseif, not multiple ones.
 I was going to move it to a switch/case, but there is no common switch.
 So I wanted to know if its technically ok, or just ok to use multiple
elseif

 Thanks


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] IF ELSEIF ELSE??

2001-08-03 Thread Richard Baskett

if (!$HTTP_POST_VARS) exit();
else {
  if (!$Age)   { echo Please enter your age.br\n; }
  if (!$Email) { echo Please enter your email.br\n; }
  if (!$State) { echo Please enter your Location.br\n;}
  if ($Age  $Email  $State) echo Thanks for your submission.;
}

Your if and else statements used every possibility up, so that last else
will never get hit.  There are a lot of things you can do better with the
above code, but it'll do what you want.  For example something you might
want to look at the type of data the person is entering, a little
validation.  I hope that helps.

Rick

 Whats wrong with this piece of code.  Basically, it not doing the last
 else statement.
 1.  If no form was submitted exit.
 2.  If a form was submitted, check for 'empty' strings.
 3.  If all is good, echo x;
 
 Thanks all.
 
 
 
 if (!$HTTP_POST_VARS) { exit(); }
 elseif ($HTTP_POST_VARS) {
 if (!$Age) { echo Please enter your age.br\n; }
if 
 (!$Email) { echo Please enter your email.br\n; }
 if (!$State) { echo Please enter your Location.br\n;}
 }
 else
 echo Thanks for your submission.;


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re:[PHP] IF ELSEIF ELSE??

2001-08-03 Thread Jack Sasportas

First you should manage your code nicer so that it is easier to read
and troubleshoot.  Go through this to find my notes...

if (!$HTTP_POST_VARS) { exit();}
elseif ($HTTP_POST_VARS) {
if (!$Age) { echo Please enter your age.br\n;
} if

Why would you use elseif above ? you are asking the full question in
the first line
if (!$HTTP_POST_VARS) { exit();}

if it's NOT then why say elseif, it's else, it's either one or the
other...that's one thing.

so lets change it to this:
if (!$HTTP_POST_VARS) {
exit();
} else {
if (!$Age) {
echo Please enter your age.br\n;
}

if (!$Email) {
echo Please enter your email.br\n;
}

if (!$State) {
echo Please enter your Location.br\n;
}

(MARK)
} else ( RIGHT HERE YOU DID NOT OPEN THE REST OF THE ELSE )
echo Thanks for your submission.;

( RIGHT HERE YOU DID NOT CLSE THEN END OF THE CONDITION )


so the last lines replacing after (MARK) should look like this

} else {
echo Thanks for your submission.;
}


As you can see keeping the code in this format makes it a lot easier to
see what is being exectued within the condition, allows you to see the
open  closes of the brackets, and should have easily let you see you
were missing something.


Hope that explains it



Re: [PHP] Re:[PHP] IF ELSEIF ELSE??

2001-08-03 Thread Richard Baskett

Just curious but that last else you told him to put in... what is that
referring to?  There is already an else statement, you can't have another.
Unless you're putting the else statement after the if (!$State) which you
would need to subtract the } before the else, but this would give you
undesired results since this is just an else for the !$State statement.

I could be missing what you were getting at.. it's definitely possible :)

Rick


 First you should manage your code nicer so that it is easier to read
 and troubleshoot.  Go through this to find my notes...
 
 if (!$HTTP_POST_VARS) { exit();}
 elseif ($HTTP_POST_VARS) {
 if (!$Age) { echo Please enter your age.br\n;
 } if
 
 Why would you use elseif above ? you are asking the full question in
 the first line
 if (!$HTTP_POST_VARS) { exit();}
 
 if it's NOT then why say elseif, it's else, it's either one or the
 other...that's one thing.
 
 so lets change it to this:
 if (!$HTTP_POST_VARS) {
 exit();
 } else {
 if (!$Age) {
 echo Please enter your age.br\n;
 }
 
 if (!$Email) {
 echo Please enter your email.br\n;
 }
 
 if (!$State) {
 echo Please enter your Location.br\n;
 }
 
 (MARK)
 } else ( RIGHT HERE YOU DID NOT OPEN THE REST OF THE ELSE )
 echo Thanks for your submission.;
 
 ( RIGHT HERE YOU DID NOT CLSE THEN END OF THE CONDITION )
 
 
 so the last lines replacing after (MARK) should look like this
 
 } else {
 echo Thanks for your submission.;
 }
 
 
 As you can see keeping the code in this format makes it a lot easier to
 see what is being exectued within the condition, allows you to see the
 open  closes of the brackets, and should have easily let you see you
 were missing something.
 
 
 Hope that explains it
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re:[PHP] IF ELSEIF ELSE??

2001-08-03 Thread Jack Sasportas

Yes, I see what you mean...
In showing why the last section didn't work, I messed up the actual
overall
logic of the code.
I should have noticed that...nice catch

so for clarification where it says (MARK) should be
echo Thanks for your submission.;
}

Thanks...

Jack Sasportas wrote:

 Yes, I see what you mean...
 In showing why the last section didn't work, I messed up the actual overall
 logic of the code.
 I should have noticed that...nice catch

 so for clarification where it says (MARK) should be
 echo Thanks for your submission.;
 }

 Thanks...

 Richard Baskett wrote:

  Just curious but that last else you told him to put in... what is that
  referring to?  There is already an else statement, you can't have another.
  Unless you're putting the else statement after the if (!$State) which you
  would need to subtract the } before the else, but this would give you
  undesired results since this is just an else for the !$State statement.
 
  I could be missing what you were getting at.. it's definitely possible :)
 
  Rick
 
   First you should manage your code nicer so that it is easier to read
   and troubleshoot.  Go through this to find my notes...
  
   if (!$HTTP_POST_VARS) { exit();}
   elseif ($HTTP_POST_VARS) {
   if (!$Age) { echo Please enter your age.br\n;
   } if
  
   Why would you use elseif above ? you are asking the full question in
   the first line
   if (!$HTTP_POST_VARS) { exit();}
  
   if it's NOT then why say elseif, it's else, it's either one or the
   other...that's one thing.
  
   so lets change it to this:
   if (!$HTTP_POST_VARS) {
   exit();
   } else {
   if (!$Age) {
   echo Please enter your age.br\n;
   }
  
   if (!$Email) {
   echo Please enter your email.br\n;
   }
  
   if (!$State) {
   echo Please enter your Location.br\n;
   }
  
   (MARK)
   } else ( RIGHT HERE YOU DID NOT OPEN THE REST OF THE ELSE )
   echo Thanks for your submission.;
  
   ( RIGHT HERE YOU DID NOT CLSE THEN END OF THE CONDITION )
  
  
   so the last lines replacing after (MARK) should look like this
  
   } else {
   echo Thanks for your submission.;
   }
  
  
   As you can see keeping the code in this format makes it a lot easier to
   see what is being exectued within the condition, allows you to see the
   open  closes of the brackets, and should have easily let you see you
   were missing something.
  
  
   Hope that explains it
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

 --
 ___
 Jack Sasportas
 Innovative Internet Solutions
 Phone 305.665.2500
 Fax 305.665.2551
 www.innovativeinternet.com
 www.web56.net

--
___
Jack Sasportas
Innovative Internet Solutions
Phone 305.665.2500
Fax 305.665.2551
www.innovativeinternet.com
www.web56.net