Norman Posted June 7, 2007 Share Posted June 7, 2007 Is possible to use more that one ElseIf? For example:if ($my_variable == 1) { echo "<p>My variable is equal to one.</p>"; } else if ($my_variable == 2) { echo "<p>My variable is equal to two.</p>"; } else if ($my_variable == 3) { echo "<p>My variable is equal to three.</p>"; } else { echo "<p>My variable is equal to neither one nor two nor three.</p>"; } Link to comment Share on other sites More sharing options...
boen_robot Posted June 7, 2007 Share Posted June 7, 2007 Well, I think if you try that out, you'll find it is indeed possible. When you evaluate only one variable though, you could also use switch(). Link to comment Share on other sites More sharing options...
Norman Posted June 7, 2007 Author Share Posted June 7, 2007 But so, is there another more better mode? If yes, wich is? The Switch Statement? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2007 Share Posted June 7, 2007 http://www.php.net/manual/en/control-structures.switch.phpSwitch only applies if you are testing one variable for multiple values. If you need to test more then one variable then the if structure is correct. Link to comment Share on other sites More sharing options...
Norman Posted June 8, 2007 Author Share Posted June 8, 2007 Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.