AV1611 Posted June 8, 2006 Share Posted June 8, 2006 Question:If I do a clause like this:IF a...elseif b...else c...and a, b, and c are ALL true,Does it do a, then ignore b & c?I need it to do only the first true it find, not all of them...Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/ Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 Yes. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43324 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 yes, because elseif implies that the if was FALSE. else implies that the if (or elseif) was FALSE. if (if this is true) { do this} elseif (since the above was not true, check if this is true. if it is true) { do this} else { since the above was not true, do this}the difference between elseif and else is that else will be executed no matter what, if the if is false, whereas the elseif will only be executed if the if is false and the elseif is true. but elseif and/or else will not be executed if the if is true. Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43340 Share on other sites More sharing options...
Barand Posted June 8, 2006 Share Posted June 8, 2006 [!--quoteo(post=381549:date=Jun 8 2006, 08:09 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 8 2006, 08:09 PM) [snapback]381549[/snapback][/div][div class=\'quotemain\'][!--quotec--]the difference between elseif and else is that else will be executed no matter what, if the if is false, whereas the elseif will only be executed if the if is false and the elseif is true. but elseif and/or else will not be executed if the if is true.[/quote]I think I preferred Poirot's answer :-) Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43365 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 i give you a cookie if you say it three times fast [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43377 Share on other sites More sharing options...
AV1611 Posted June 8, 2006 Author Share Posted June 8, 2006 LOLYES...that was the answer I was looking for...I just wanted to make sure I didn't need to add some safety net, because I am doing a script that would be devastating if the ELSE executed after the IF had already executed... :X Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43392 Share on other sites More sharing options...
Barand Posted June 9, 2006 Share Posted June 9, 2006 It was easily verifiable by adding an echo statement in each of the if/elseif bits. Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43447 Share on other sites More sharing options...
AV1611 Posted June 9, 2006 Author Share Posted June 9, 2006 Yea, I thought of that after I had already done this thread :? Quote Link to comment https://forums.phpfreaks.com/topic/11508-elseif/#findComment-43672 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.