PHP 조건부 연산자

(PHP ? :에서 넘어옴)

1 개요[ | ]

PHP conditional operator, PHP ternary operator
PHP 조건부 연산자, PHP 삼항 연산자
$score = 50;
$grade = $score > 80 ? 'A' : 'B';
echo $grade;
$_POST = ['action' => 'edit'];
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
echo $action;
$_POST = [];
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
echo $action;

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}