php - Ternary operator and string concatenation quirk? -
hi want know why code yields (at least me) incorrect result.
well, i'm in fault here
$description = 'paper: ' . ($papertype == 'bond') ? 'bond' : 'other';
i guessing if papertype equals 'bond' description 'paper: bond' , if papertype not equals 'bond' description 'paper: other'.
but when run code results description either 'bond' or 'other' , left me wondering string 'paper: ' went???
$description = 'paper: ' . ($papertype == 'bond' ? 'bond' : 'other');
try adding parentheses string concatenated string in right order.
Comments
Post a Comment