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 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 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 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 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"; ?> 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/ 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 Link to comment https://forums.phpfreaks.com/topic/147101-solved-wtf-is-this/#findComment-772327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.