This is only available since PHP 5.3
The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.1
See this example for more context.
or a more useful but note in the comments: http://www.php.net/manual/en/control-structures.if.php#102060
1http://php.net/manual/en/language.operators.comparison.php
Answer from azat on Stack OverflowVideos
This is only available since PHP 5.3
The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.1
See this example for more context.
or a more useful but note in the comments: http://www.php.net/manual/en/control-structures.if.php#102060
1http://php.net/manual/en/language.operators.comparison.php
Since you are using php 5.2.16, your ternary requires 2 options e.g
x ? $x : "Some default";
Variable = condition ? true value : false value ;
?: is a form of the conditional operator which was previously available only as:
expr ? val_if_true : val_if_false
In 5.3 it's possible to leave out the middle part, e.g. expr ?: val_if_false which is equivalent to:
expr ? expr : val_if_false
From the manual:
Since PHP 5.3, it is possible to leave out the middle part of the conditional operator. Expression
expr1 ?: expr3returnsexpr1ifexpr1evaluates toTRUE, andexpr3otherwise.
The ?: operator is the conditional operator (often refered to as the ternary operator):
The expression
(expr1) ? (expr2) : (expr3)evaluates toexpr2ifexpr1evaluates to TRUE, andexpr3ifexpr1evaluates to FALSE.
In the case of:
expr1 ?: expr2
The expression evaluates to the value of expr1 if expr1 is true and expr2 otherwise:
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression
expr1 ?: expr3returnsexpr1ifexpr1evaluates to TRUE, andexpr3otherwise.