jd2007 Posted July 21, 2007 Share Posted July 21, 2007 Is there a shorter way of doing if...else statement...i know there is one..how to do it? Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 21, 2007 Share Posted July 21, 2007 ternary operation... $var = !empty($var) : $var = 'not empty' ? $var = 'empty'; Quote Link to comment Share on other sites More sharing options...
jd2007 Posted July 21, 2007 Author Share Posted July 21, 2007 thanks... Quote Link to comment Share on other sites More sharing options...
burtybob Posted July 21, 2007 Share Posted July 21, 2007 You can use switch as well, http://us2.php.net/switch Quote Link to comment Share on other sites More sharing options...
jd2007 Posted July 21, 2007 Author Share Posted July 21, 2007 deadevil, your code is wrong, its actually : $var = !empty($var) ? $var = 'not empty' : $var = 'empty'; Quote Link to comment Share on other sites More sharing options...
Barand Posted July 21, 2007 Share Posted July 21, 2007 Both wrong $var = !empty($var) ? 'not empty' : 'empty'; Quote Link to comment Share on other sites More sharing options...
burtybob Posted July 21, 2007 Share Posted July 21, 2007 just use switch seems like its the easiest and least complicated way of doing it! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 21, 2007 Share Posted July 21, 2007 just use switch seems like its the easiest and least complicated way of doing it! ternary operation is far better if you are only comparing one value. You'd use switch if you are going to be comparing multiple values. Quote Link to comment Share on other sites More sharing options...
burtybob Posted July 21, 2007 Share Posted July 21, 2007 just use switch seems like its the easiest and least complicated way of doing it! ternary operation is far better if you are only comparing one value. You'd use switch if you are going to be comparing multiple values. oh... Ok thanks for that little bit of information i will remember that now! 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.