jnvnsn Posted June 22, 2011 Share Posted June 22, 2011 I am fixing somebody else's code and i'm bothered by this: <?php echo $r_pop ? "1" : "0";?> can anyone explain this line for me? Quote Link to comment https://forums.phpfreaks.com/topic/240143-unexplained-lines/ Share on other sites More sharing options...
Maq Posted June 22, 2011 Share Posted June 22, 2011 Read the manual - Ternary Operator. The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE. Quote Link to comment https://forums.phpfreaks.com/topic/240143-unexplained-lines/#findComment-1233487 Share on other sites More sharing options...
jnvnsn Posted June 22, 2011 Author Share Posted June 22, 2011 It is the first time i've encountered about his Maq. Thank you so much, you've been of a great help! Quote Link to comment https://forums.phpfreaks.com/topic/240143-unexplained-lines/#findComment-1233493 Share on other sites More sharing options...
The Little Guy Posted June 22, 2011 Share Posted June 22, 2011 Maq, your link is wrong. that is the same as this, basically it is short hand: <?php if($r_pop){ echo "1"; }else{ echo "0"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/240143-unexplained-lines/#findComment-1233494 Share on other sites More sharing options...
Maq Posted June 22, 2011 Share Posted June 22, 2011 Sorry, here you go - Ternary Operator. Quote Link to comment https://forums.phpfreaks.com/topic/240143-unexplained-lines/#findComment-1233500 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.