DamienRoche Posted September 10, 2008 Share Posted September 10, 2008 I have wrote this simple if statement, along with a nested if statement. if ($var =="yes") { if($var2 !="" && $var3 !=""){ /////do some stuff } } The problem I'm having is that the if statement nested inside the first if statement runs regardless of whether the first statement is satisfied or not. It doesn't make any sense to me because as far as I know it shouldn't even be looking at that code unless the if statement is satisfied. Am I missing something? Link to comment https://forums.phpfreaks.com/topic/123561-solved-problem-running-if-statement/ Share on other sites More sharing options...
JasonLewis Posted September 10, 2008 Share Posted September 10, 2008 Sounds like $var does, in fact, equal "yes". $var = "no"; $var2 = "text"; $var3 = "here"; if($var == "yes"){ if($var2 != "" && $var3 != ""){ echo "It should never get here!"; } } That code does not echo anything for me. Link to comment https://forums.phpfreaks.com/topic/123561-solved-problem-running-if-statement/#findComment-638151 Share on other sites More sharing options...
DamienRoche Posted September 10, 2008 Author Share Posted September 10, 2008 Ya know what I should have done? echoed the variables...turns out there was a missing character causing issues. Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/123561-solved-problem-running-if-statement/#findComment-638152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.