The following results in $c
getting 'a', when intuition says it should get tie
. What is going on here?
$a = 3;
$b = 3;
$c = $a === $b ? 'tie' : $a > $b ? 'a' : 'b';
var_dump($c); // shows a
The following results in $c
getting 'a', when intuition says it should get tie
. What is going on here?
$a = 3;
$b = 3;
$c = $a === $b ? 'tie' : $a > $b ? 'a' : 'b';
var_dump($c); // shows a
Yo need to put the code between ()
$a = 3;
$b = 3;
$c = ($a === $b ? 'tie' : ($a > $b ? 'a' : 'b'));
$a = 3;
$b = 3;
$c = ($a === $b) ? 'tie' : (($a > $b) ? 'a' : 'b');
var_dump($c);