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";
?>