Dale_G Posted May 10, 2008 Share Posted May 10, 2008 Well, if you don't get my question from the topic alone.. What's the difference between an if and an elseif. When should one use an elseif INSTEAD of an if, maybe using a short code example? Quote Link to comment Share on other sites More sharing options...
Fadion Posted May 10, 2008 Share Posted May 10, 2008 This will only echo the text if $myname is guilty. if($myname == 'guilty'){ echo 'Right.'; } This will echo 'Right' if $myname is guilty, but echo 'Nope' if $myname isnt guilty if($myname == 'guilty'){ echo 'Right'; } else{ echo 'Nope'; } This elseif will check the first if() and if it returns true, it stops checking the other elseif() and else, otherwise it will continue until a statement is true or until the else: if($myname == 'guilty'){ echo 'Right'; } elseif($myname == 'gear'){ echo 'Probably'; } else{ echo 'Nope'; } Get it now? Quote Link to comment Share on other sites More sharing options...
Dale_G Posted May 10, 2008 Author Share Posted May 10, 2008 Why..yes! Yes I do now. Thanks! Quote Link to comment 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.