I have already seen the thread PHP ternary operator error
I have seen the thread mentioned above and am using parenthesis but still it doesn't give the expected output.
<?php
$ch = 'A';
$ans = (($ch == 'C') ? 'Cccc'
: ($ch == 'A') ? 'Aaaa'
: ($ch == 'G') ? 'Ggggg'
: ($ch == 'Y') ? 'Yyyyy'
: 'unknown');
echo $ans;
echo "\n";
?>
This outputs Yyyyy
and not Aaaa
as expected. Can anyone explain why ?