snowman15 Posted July 26, 2007 Share Posted July 26, 2007 Hey, am i missing something? <?php $lol=2; if ($lol="1") { echo $hello="hello"; } ?> It keeps displaying hello even though the line right above it does not make the condition true. Am i missing something about these if statements? Link to comment https://forums.phpfreaks.com/topic/61806-if-statement-not-working-quick-question/ Share on other sites More sharing options...
clearstatcache Posted July 26, 2007 Share Posted July 26, 2007 just simple error in syntax .... if ($lol=="1") instead of if ($lol="1") Link to comment https://forums.phpfreaks.com/topic/61806-if-statement-not-working-quick-question/#findComment-307789 Share on other sites More sharing options...
DeadEvil Posted July 26, 2007 Share Posted July 26, 2007 <?php $lol=2; if ($lol==1){ echo $hello="hello"; } else { echo $hello=$lol; } ?> Link to comment https://forums.phpfreaks.com/topic/61806-if-statement-not-working-quick-question/#findComment-307799 Share on other sites More sharing options...
rameshfaj Posted July 26, 2007 Share Posted July 26, 2007 <?php $lol=2; if ($lol="1") { echo $hello="hello"; } ?> U need to compare not to initialize the value to something.Here u were initializing the value not comparing. So use this or as mentioned above. <?php $lol=2; if ($lol==1)//not "1" bcoz quotations only used for strings here { echo $hello="hello"; } ?> Link to comment https://forums.phpfreaks.com/topic/61806-if-statement-not-working-quick-question/#findComment-307894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.