$a = $b != $c ? $d : $b != $c ? $d : $b != $c ? $d : $x; <<<--- this, doesn't work $a = $b != $c ? $d : $b == $c ? $d : $b == $c ? $d : $x; <<<--- this works $a = $b == $c ? $d : $b != $c ? $d : $b == $c ? $d : $x; <<<--- this works $a = $b == $c ? $d : $b == $c ? $d : $b == $c ? $d : $x; <<<--- this of course works
It is the first time I did several negative loops together and it just was my doubt.$a = ($b != $c) ? $d : ($b != $c) ? $d : ($b != $c) ? $d : $x; <<<--- this, doesn't work
K-Meleon in Spanish
$b = 1; $c = 2; $d = 3; $x = 4 ; #<<<--- this, doesn't work $a = $b != $c ? $d : $b != $c ? $d : $b != $c ? $d : $x; #when b&c are 1 a equal 4 %%% 1st false 2nd false 3rd false #when b=1 and c=2 a equal 3 %%% 1st true alert($a, "first value of $a"); #<<<--- this works $a = $b != $c ? $d : $b == $c ? $d : $b == $c ? $d : $x; #when b&c are 1 a equal 3 %%% 1st false 2nd true #when b=1 and c=2 a equal 3 %%% 1st true alert($a, "second value of $a"); #<<<--- this works $a = $b == $c ? $d : $b != $c ? $d : $b == $c ? $d : $x; #when b&c are 1 a equal 3 %%% 1st true #when b=1 and c=2 a equal 3 %%% 1st false 2nd true alert($a, "third value of $a"); #<<<--- this of course works $a = $b == $c ? $d : $b == $c ? $d : $b == $c ? $d : $x; #when b&c are 1 a equal 3 %%% 1st true #when b=1 and c=2 a equal 4 %%% 1st false 2nd false 3rd false alert($a, "fourth value of $a"); ##Are you tried with "()": $a = ($b != $c) ? $d : ($b != $c) ? $d : ($b != $c) ? $d : $x; #when b&c are 1 a equal 4 %%% 1st false 2nd false 3rd false #when b=1 and c=2 a equal 3 %%% 1st true alert($a, "fifth value of $a");
$b = 1; $c = 2; $d = 3; $x = 4 ; #<<<--- this,doesn'twork $a = $b != $c ? $d : $b != $c ? $d : $b != $c ? $d : $x; #when b&c are 1 a equal 4 %%% 1st false 2nd false 3rd false #when b=1 and c=2 a equal 3 %%% 1st true alert($a, "first value of $a"); # Alert show a=3, this is correct, B and C are differents A=D=3, rest of expresion aren't evaluated because the first is true and a true value in first only asign A=D # If B=C=1 then A=X=4 because 1st false 2nd false 3rd false
$a = $b != $c ? $d : $x;
$a = $b != $c ? $d : $b != $d ? $c : $b != $x ? $d : $c; #when b&c are 1 a equal 1 %%% 1st false 2nd true 3rd not checked #when b=1 and c=2 a equal 3 %%% 1st true # Or something like this: $a = $b != $c ? ($b != $d ? $c : $d) : ($b != $x ? $d : $c);
K-Meleon in Spanish
$a = 0; $b = 1; $c = 1; $d = 1; $x = 4; $y = 5;With this data the answer is 4. The code does exactly what it is supposed to do. With the original data, the first condition is true and nothing to the right of the : is executed.
Not problem, everyone have stupid days when start program in a new language.
K-Meleon in Spanish

