WA
12-14-2002, 02:32 AM
Hi:
Is it possible to use more than 2 expressions in a ternary operator in PHP? Apparently the below, with 3 expressions, doesn't work when I tried it:
$inputpass=isset($test)? $test : isset($test2)? $test2 : "";
In JavaScript, the same concept works, so I'm curious why it doesn't in PHP. Basically the logic is to set $inputpass to three different values, depending on whether $test or $test2 is defined.
Thanks,
Is it possible to use more than 2 expressions in a ternary operator in PHP? Apparently the below, with 3 expressions, doesn't work when I tried it:
$inputpass=isset($test)? $test : isset($test2)? $test2 : "";
In JavaScript, the same concept works, so I'm curious why it doesn't in PHP. Basically the logic is to set $inputpass to three different values, depending on whether $test or $test2 is defined.
Thanks,