tet3828 Posted January 29, 2008 Share Posted January 29, 2008 is it against the laws of PHP to nest a if/else within a "elseif { }" I keep getting Parse error: syntax error, unexpected T_ELSEIF Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/ Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 Probably means you forgot the first IF to start it. Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452756 Share on other sites More sharing options...
PHP Monkeh Posted January 29, 2008 Share Posted January 29, 2008 Lets see what you've got and we'll point out where you went wrong ^.^ Edit: or just listen to rev Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452757 Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 You can't do elseif { elseif { } } But you can do elseif { } elseif { } Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452759 Share on other sites More sharing options...
tet3828 Posted January 29, 2008 Author Share Posted January 29, 2008 Perhaps I have not explained myself well enough. I already have a few: elseif {} elseif {} those work just fine, but what I was wondering is if I can: elseif { if { }else { }} You guys are most likely on the right track I'd better check my brackets. You all would laugh your socks off if you saw my code. Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452798 Share on other sites More sharing options...
kratsg Posted January 29, 2008 Share Posted January 29, 2008 Let's see it. I'm in the mood for some laughs Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452802 Share on other sites More sharing options...
cooldude832 Posted January 29, 2008 Share Posted January 29, 2008 Its not "against the law" but its better to uses switches and functional programing were it makes sense This is legal <?php if(){ if(){ if(){ } elseif(){ if(){ } elseif(){ } } else{ } } elseif(){ if(){ if(){ } else{ } } } } elseif(){ if(){ if(){ } } } elseif(){ if(){ } } else{ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452805 Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 That looks fine, you can do a new IF in a elseif. Perhaps I have not explained myself well enough. I already have a few: elseif {} elseif {} those work just fine, but what I was wondering is if I can: elseif { if { }else { }} You guys are most likely on the right track I'd better check my brackets. You all would laugh your socks off if you saw my code. Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452808 Share on other sites More sharing options...
kratsg Posted January 29, 2008 Share Posted January 29, 2008 That looks fine, you can do a new IF in a elseif. Perhaps I have not explained myself well enough. I already have a few: elseif {} elseif {} those work just fine, but what I was wondering is if I can: elseif { if { }else { }} You guys are most likely on the right track I'd better check my brackets. You all would laugh your socks off if you saw my code. What if he literally was doing: elseif { if(){}else{} } Instead of: elseif(){ if(){}else{} } Or he forgot parentheses somewhere instead of curly brackets. Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452812 Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 What if he forgot a lot of things...? He asked what is legal syntax, not if he got confused and forgot something. Or he forgot parentheses somewhere instead of curly brackets. Quote Link to comment https://forums.phpfreaks.com/topic/88459-elseif-if-else-nesting-possible/#findComment-452816 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.