Re: [PHP] elseif without else
If you are setting a variable inside of the if statements, and then checking that variable later, then I would say you should either use an else statement to give that variable a default value, or you should set the variable to a default value before the if statements Your code is legitimate, ie there is no reason you *have* to have an else statement Jeff At 07:32 PM 2/28/2002 -0500, Erik Price wrote: For any of you PHP legal eagles: I rtfm'd, but the elseif page doesn't say -- is it okay to have if ($x) { // do something } elseif ($y) { // do something } elseif ($z) { // do something } without a final else? My code works fine -- so I know that you -can- do this What I was wondering is if this is something that is likely to get deprecated at some point in the future IOW, is it legitimate, regardless of how it works? Thanks, Erik PS: is it bad coding style to do the above? I'd like comments on that too if applicable My if statements check for conditions and then set a variable, and later in the script if that variable exists then something else happens Is this sloppy? -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] elseif without else
Perfectly legitimate... it is much like having a switch statement without a default clause. - Original Message - From: Erik Price [EMAIL PROTECTED] To: PHP (E-mail) [EMAIL PROTECTED] Sent: Thursday, February 28, 2002 7:32 PM Subject: [PHP] elseif without else For any of you PHP legal eagles: I rtfm'd, but the elseif page doesn't say -- is it okay to have if ($x) { // do something } elseif ($y) { // do something } elseif ($z) { // do something } without a final else? My code works fine -- so I know that you -can- do this. What I was wondering is if this is something that is likely to get deprecated at some point in the future. IOW, is it legitimate, regardless of how it works? Thanks, Erik PS: is it bad coding style to do the above? I'd like comments on that too if applicable. My if statements check for conditions and then set a variable, and later in the script if that variable exists then something else happens. Is this sloppy? Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- 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] elseif without else
if there's nothing to do in the else block, then it's a bit pointless to have one eg input type=checkbox? if ($blah) echo checked; ? value=xxx name=blah see what I mean? Martin -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: Friday, March 01, 2002 11:32 AM To: PHP Subject: [PHP] elseif without else For any of you PHP legal eagles: I rtfm'd, but the elseif page doesn't say -- is it okay to have if ($x) { // do something } elseif ($y) { // do something } elseif ($z) { // do something } without a final else? My code works fine -- so I know that you -can- do this. What I was wondering is if this is something that is likely to get deprecated at some point in the future. IOW, is it legitimate, regardless of how it works? Thanks, Erik PS: is it bad coding style to do the above? I'd like comments on that too if applicable. My if statements check for conditions and then set a variable, and later in the script if that variable exists then something else happens. Is this sloppy? Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] elseif without else
On Thursday, February 28, 2002, at 07:56 PM, Dennis Moore wrote: Perfectly legitimate... it is much like having a switch statement without a default clause. Oh, I didn't know that that was legitimate either. :) Thanks Dennis Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php