ngreenwood6 Posted October 3, 2009 Share Posted October 3, 2009 I am trying to do an inline if statement. I havent done it in awhile so I forget the correct syntax but if I wanted to put this code on one line how would I do it? if(isset($_GET['test'])) { $message = $_GET['test']; } else { $message = ''; } Any help is appreciated. I know it is a ? and a : but cant remember it exactly lol Quote Link to comment Share on other sites More sharing options...
Alex Posted October 3, 2009 Share Posted October 3, 2009 The format is: $var = (expression) ? 'what to make it if the expression is true' : 'what to make it if it is false'; so: $message = (isset($_GET['test'])) ? $_GET['test'] : NULL; Quote Link to comment Share on other sites More sharing options...
lipun4u Posted October 3, 2009 Share Posted October 3, 2009 $message = (isset($_GET['test']) ? $_GET['test'] : ''); Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted October 3, 2009 Author Share Posted October 3, 2009 Thanks a million guys. Needed a refresher lol 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.