三元算子中的多个条件[关闭]

I want to check if a variable is equal to b or c using tertiary operator. is it possible to do that?

 $value = ($variable == 'b' or 'c')? true: false;

Is this possible?

Yes, separate your conditions using || operator, like so:

$value = ($variable == 'a' || $variable == 'b') ? true : false;

However, for this particular case, a ternary operator isn't necessary! You can directly use the return value:

$value = ($variable == 'a' || $variable == 'b');

Try the following

$value = ($variable == 'a' || $variable == 'b')? true: false;

No need Ternary Operator!

Try the following

$value = ($variable == 'a' || $variable == 'b');