Monkuar Posted February 27, 2009 Share Posted February 27, 2009 $ibforums->input['allow_msg'] = $ibforums->input['allow_msg'] == 'yes' ? 1 : 0; Forgot the $ibforums but what is the == 'yes' ? 1: 0 ; can some smart php person tell me in real life on what exactly does it do? lol thx Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/ Share on other sites More sharing options...
angelcool Posted February 27, 2009 Share Posted February 27, 2009 Ternary operator. It is like an if else statement. http://us.php.net/operators.comparison I feel smart now!. Angel Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772273 Share on other sites More sharing options...
MadTechie Posted February 27, 2009 Share Posted February 27, 2009 its a short if (aka Ternary operator) ie $admin = ($name == "madtechie")?true:false; //is the same as if($name == "madtechie") { $admin = true; }else{ $admin = false; } //which of couse in this case would be the same as $admin = ($name == "madtechie"); //but you should get the idea! EDIT: forgot the false! part Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772277 Share on other sites More sharing options...
Monkuar Posted February 27, 2009 Author Share Posted February 27, 2009 ternary operator? omg im lost, wow Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772279 Share on other sites More sharing options...
MadTechie Posted February 27, 2009 Share Posted February 27, 2009 think of it as a oneline if you know the lines for example <?php if($sales > 100) { echo "Target Hit"; }else{ echo "Target missed"; } ?> 6 lines of code for what!! a hit or miss! well thats all fine and dandy.. but some times you want to type less.. So we get this <?php echo ($sales > 100)?"Target Hit":"Target missed"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772290 Share on other sites More sharing options...
unrelenting Posted February 27, 2009 Share Posted February 27, 2009 This helped me a lot with the ternary conditional. I use them all the time now. http://www.addedbytes.com/php/ternary-conditionals/ Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772298 Share on other sites More sharing options...
Monkuar Posted February 27, 2009 Author Share Posted February 27, 2009 ty sir Quote Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772327 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.