networkthis Posted May 9, 2008 Share Posted May 9, 2008 $name = isset($_POST['name']) ? $_POST['name'] : ""; I have seen this in some sample forms online and I am just trying to make sure that I am understanding it properly. I am trying to learn the language to build smarter php forms. Any help would be great. isset -- checks to see if the variable has a value........Therefore, isset($_POST['name']) is checking to see that ($_POST['name']) has a value ? - What does the ? mean in this statement $_POST['name'] :"" --- What does the :"" mean in this statement Thank you in advance for your help Quote Link to comment https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/ Share on other sites More sharing options...
DeanWhitehouse Posted May 9, 2008 Share Posted May 9, 2008 erm, ok i just heard this a few minutes ago, ? that sets what happens if it is true or not for example this $variable_name = (clause) ? true:false; Quote Link to comment https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/#findComment-537190 Share on other sites More sharing options...
networkthis Posted May 9, 2008 Author Share Posted May 9, 2008 Thanks for the quick response so $name = isset($_POST['name']) ? $_POST['name'] : ""; means: if $name has a value then set the value to what was inputed in $_POST['name'] if $name has no value then set it equal to nothing (") You rock...thank you!!! Quote Link to comment https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/#findComment-537196 Share on other sites More sharing options...
maxudaskin Posted May 9, 2008 Share Posted May 9, 2008 <?php $string = isset($isset) ? "Yes" : "No"; echo $string; ?> Outputs No <?php $isset = 1; $string = isset($isset) ? "Yes" : "No"; echo $string; ?> Outputs Yes Quote Link to comment https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/#findComment-537197 Share on other sites More sharing options...
networkthis Posted May 10, 2008 Author Share Posted May 10, 2008 Thanks for all your help! Quote Link to comment https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/#findComment-537198 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 If you ever need to look it up, it's called the ternary operator. Quote Link to comment https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/#findComment-537204 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.