$httpHost = !empty($httpHost) ?: $_SERVER['HTTP_HOST'];
Hi, are you sure this syntax is valid ? It seems it miss something between the ? and :
See http://us2.php.net/ChangeLog-5.php. Search for 'Added "?:" operator. (Marcus)' in the 5.3.0 section.
It's basically shorthand for the usual ? : operator, when the second argument is supposed to be the same as the first. Read the second paragraph after "Example #2" at http://us2.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary for the official documentation of this feature.
Hmm.. Really bad example. The better one is:
$x = $a ?: $b; //elvis (coalesce, short ternary, etc) operator available since PHP 5.3
is equivalent to
$x = $a ? $a : $b;
But in first case i`m getting the syntax error from PHParser plugin.
fixed in trunk
Log in to post a comment.
Hi, are you sure this syntax is valid ? It seems it miss something between the ? and :
See http://us2.php.net/ChangeLog-5.php. Search for 'Added "?:" operator. (Marcus)' in the 5.3.0 section.
It's basically shorthand for the usual ? : operator, when the second argument is supposed to be the same as the first.
Read the second paragraph after "Example #2" at http://us2.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary for the official documentation of this feature.
Hmm.. Really bad example.
The better one is:
$x = $a ?: $b; //elvis (coalesce, short ternary, etc) operator available since PHP 5.3
is equivalent to
$x = $a ? $a : $b;
But in first case i`m getting the syntax error from PHParser plugin.
fixed in trunk