php ternární operátor
(Condition) ? (Statement1) : (Statement2);
php inline pokud
/* most basic usage */
$var = 5;
$var_is_greater_than_two = ($var > 2 ? true : false); // returns true
php ternární operátor
<?php
#Syntex
(if Condition) ? (stat1) : (stat2);
#example
$var1 = 5;
$var2 = 2;
echo $check = ($var1 > $var2) ? "right" : "wrong";
#output : right
/*
explination : if condition is true then display the stat1 and if condition is
worng then display stat2
*/
?>
ternární operátor v php
<?php
$marks=40;
print ($marks>=40) ? "pass" : "Fail";
?>
php ternární
$result = $condition ? 'foo' : 'bar';
napište if a else do jednoho řádku php
$result = ($data->status == 1) ? 'active' : 'disable'
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'
}