From PHP 5.3, the middle part of the ternary operator can be omitted. Expression expr1?: Expr3 returns EXPR1 when EXPR1 evaluates to TRUE, otherwise returns EXPR3.
<?PHP$test= ' Rookie Tutorial ';//General Wording$username=isset($test) ?$test: ' Nobody ';Echo $username,Php_eol;//PHP 5.3+ version notation$username=$test?: ' Nobody ';Echo $username,Php_eol;?>
Note: Php_eol is a newline character that is compatible with larger platforms.
A NULL merge operator was added to the php7+ version, with the following example:
<? PHP // if $_get[' user '] does not exist return ' nobody ', return the value of $_get[' user '] $username $_get [' User ']?? ' Nobody '; // a similar ternary operator $username isset ($_get$_get[' User ']: ' Nobody ';? >
Combination Comparer (php7+)
php7+ supports combined comparators, as follows:
<?PHP//Integral typeEcho1 <=> 1;//0Echo1 <=> 2;//-1Echo2 <=> 1;//1//floating point typeEcho1.5 <=> 1.5;//0Echo1.5 <=> 2.5;//-1Echo2.5 <=> 1.5;//1//StringEcho"A" <=> "a";//0Echo"A" <=> "B";//-1Echo"B" <=> "a";//1?>
New PHP notation