php ternární operátor
(Condition) ? (Statement1) : (Statement2);
ternární operátor v php
<?php
$marks=40;
print ($marks>=40) ? "pass" : "Fail";
?>
php ternární
$result = $condition ? 'foo' : 'bar';
php ternární
$result = $condition ? 'foo' : 'bar';
ternární v php
print ($marks>=40) ? "pass" : "Fail";
php ternární operátoři
// Both ternary and if/else returns the same result
// ternary
$result = $condition ? 'foo' : 'bar';
// if/else
if ($condition) {
$result = 'foo'
} else {
$result = 'bar'
}
?? ternární operátor v php
echo $color = $color ?? 'red'; //if value not exists then assign to them.
ternární operátor pro tři podmínky v php
$foo = your_value;
$bar = ($foo == 1) ? "1" : (($foo == 2) ? "2" : "other");
echo $bar;
ternární operátor v php
<?php
$x=4;
$y=3;
if(x>y)?echo"X is large": echo "y is large";
?>