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? Quote Link to comment 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") Quote Link to comment 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; } ?> Quote Link to comment 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"; } ?> 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.