php三元运算符
(Condition) ? (Statement1) : (Statement2);
php中的三元运算符
<?php
$marks=40;
print ($marks>=40) ? "pass" : "Fail";
?>
php三元
$result = $condition ? 'foo' : 'bar';
php三元
$result = $condition ? 'foo' : 'bar';
php中的三元
print ($marks>=40) ? "pass" : "Fail";
php三元运算符
// Both ternary and if/else returns the same result
// ternary
$result = $condition ? 'foo' : 'bar';
// if/else
if ($condition) {
$result = 'foo'
} else {
$result = 'bar'
}
?? 三操作员在php
echo $color = $color ?? 'red'; //if value not exists then assign to them.
三操作人员对三个条件中的php
$foo = your_value;
$bar = ($foo == 1) ? "1" : (($foo == 2) ? "2" : "other");
echo $bar;
三操作员在php
<?php
$x=4;
$y=3;
if(x>y)?echo"X is large": echo "y is large";
?>