PHP üçlü operatör
(Condition) ? (Statement1) : (Statement2);
php'de üçlü operatör
<?php
$marks=40;
print ($marks>=40) ? "pass" : "Fail";
?>
php üçlü
$result = $condition ? 'foo' : 'bar';
php üçlü
$result = $condition ? 'foo' : 'bar';
php'de üçlü
print ($marks>=40) ? "pass" : "Fail";
PHP üçlü operatörler
// Both ternary and if/else returns the same result
// ternary
$result = $condition ? 'foo' : 'bar';
// if/else
if ($condition) {
$result = 'foo'
} else {
$result = 'bar'
}
?? php'de üçlü operatör
echo $color = $color ?? 'red'; //if value not exists then assign to them.
php'de üç koşul için üçlü operatör
$foo = your_value;
$bar = ($foo == 1) ? "1" : (($foo == 2) ? "2" : "other");
echo $bar;
php'de üçlü operatör
<?php
$x=4;
$y=3;
if(x>y)?echo"X is large": echo "y is large";
?>