Let’s look at a ternary operation formula first:
Copy the code The code is as follows:
$a=1;$b=2;$c=3;$d=4;
echo $a<$b?'xx':$a<$c?'yy':$a<$d?'zz':'oo';
?>
Copy the code The code is as follows:
$a<$b => true => 'xx' ==> End
Copy the code The code is as follows:
$a=1;$b=2;$c=3;$d=4;
echo (($a<$b?'xx': $a<$c)?'yy':$a<$d)?'zz':'oo';
?>
Copy Code The code is as follows:
$a<$b => true => 'xx' => true => 'yy' => true => 'zz' => End
Copy the code The code is as follows:
$a=1;$b=2; $c=3;$d=4;
echo $a<$b?'xx':($a<$c?'yy':($a<$d?'zz':'oo'));
// Just change the position of the brackets. You can’t omit brackets in PHP
?>
The above has introduced the combined introduction of wedding songs, songs suitable for weddings, and PHP ternary operators, including wedding songs, songs suitable for weddings, and I hope it will be helpful to friends who are interested in PHP tutorials.