operador ternario php
(Condition) ? (Statement1) : (Statement2);
operador ternario en php
<?php
$marks=40;
print ($marks>=40) ? "pass" : "Fail";
?>
php ternary
$result = $condition ? 'foo' : 'bar';
php ternario
$result = $condition ? 'foo' : 'bar';
ternary en php
print ($marks>=40) ? "pass" : "Fail";
operadores ternarios php
// Both ternary and if/else returns the same result
// ternary
$result = $condition ? 'foo' : 'bar';
// if/else
if ($condition) {
$result = 'foo'
} else {
$result = 'bar'
}
?? operador ternario en php
echo $color = $color ?? 'red'; //if value not exists then assign to them.
operador ternario para tres condiciones en php
$foo = your_value;
$bar = ($foo == 1) ? "1" : (($foo == 2) ? "2" : "other");
echo $bar;
operador ternario en php
<?php
$x=4;
$y=3;
if(x>y)?echo"X is large": echo "y is large";
?>