A nice alternative is to use the “or” operator: $value = $planA or $value = planB; So the end result is the same as just concatenating the value anyway: In your echo example at the start of your question, what you're conditionally outputting is a whitespace character. So when creating a ternary we can block it out in three parts: variable = expression part ? It is called a ternary operator because it takes three operands- a condition, a result statement for true and a … This above pictorial helps you to understand the concept of LOGICAL AND operation with an analogy of taps and water. How does PHP evaluate multiple conditionals? Which explains that if both of conditions are FALSE or 0, the return is FALSE or 0. How to use a variable for a key in a JavaScript object literal? Suppose you just want to execute a function, or do multiple operations… don’t use ternaries. The ternary operator provides a shorthand way of writing the if...else statements. Take note when grouping ternary operations that return either boolean or integer concatenated to a string: a function to help settings default values, it returns its own first non-empty argument : Note: The ternary shortcut currently seems to be of no use in dealing with unexisting keys in an array, as PHP will throw an error. La conversion de type n'intervient pas lorsque la comparaison est alors la comparaison sera effectuée numériquement. Tell us what’s happening: It says to Use multiple conditional operators in the checkSign function to check if a number is positive, negative or zero. Things The ternary operator will use its lefthand operand when the condition  Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Ternary shorthand. I couldn't find much info on stacking the new ternary operator, so I ran some tests: note: the behavior below is documented in the appendix K about type comparisons, but since it is somewhat buried i thought i should raise it here for people since it threw me for a loop until i figured it out completely. ne s'évalue pas comme une variable, mais comme le résultat d'une expression. PHP's behaviour when using more than one ternary operator within a single  php,html,select,drop-down-menu It is because you aren't ending the value attribute, so your selected option becomes