"PHP 조건부 연산자"의 두 판 사이의 차이

23번째 줄: 23번째 줄:


==참고==
==참고==
* https://www.php.net/manual/en/language.operators.comparison.php
* https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary


[[분류: PHP 연산자]]
[[분류: PHP 연산자]]

2021년 7월 16일 (금) 10:31 판

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 }}