arunpatal Posted November 15, 2012 Share Posted November 15, 2012 This is my if else statement.... But it dose not show $codes1 Is something wrong with it??? <?php if(isset($codes3)) { echo"<br/><div id='codedisplay_box' style='overflow: auto;'><code><xmp> $codes3</xmp></code></div><br/>"; } else { echo"<div id='codedisplay_box' style='overflow: auto;'><code><xmp>$codes1</xmp></code></div>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/270761-if-and-else/ Share on other sites More sharing options...
requinix Posted November 16, 2012 Share Posted November 16, 2012 Apparently so, since it doesn't do what you want it to do. If the $codes1 string isn't being shown then isset($codes3). If the string is being shown and that value is empty then, well, that value is empty. Quote Link to comment https://forums.phpfreaks.com/topic/270761-if-and-else/#findComment-1392808 Share on other sites More sharing options...
cyberRobot Posted November 16, 2012 Share Posted November 16, 2012 Did you try using something like var_dump() to see what $codes1 and $codes3 actually contain? http://php.net/manual/en/function.var-dump.php Quote Link to comment https://forums.phpfreaks.com/topic/270761-if-and-else/#findComment-1392945 Share on other sites More sharing options...
Jessica Posted November 16, 2012 Share Posted November 16, 2012 You need to start using descriptive variable names. Quote Link to comment https://forums.phpfreaks.com/topic/270761-if-and-else/#findComment-1392946 Share on other sites More sharing options...
MDCode Posted November 16, 2012 Share Posted November 16, 2012 Just because $codes3 isn't set, doesn't mean that $codes1 is set. There's no way to tell by that snippet you've shown. Quote Link to comment https://forums.phpfreaks.com/topic/270761-if-and-else/#findComment-1392948 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.