채택완료

변수 2개 를 $ca_name 에 넣기.. 쉽게 만들기...

Copy
$ca_name = (isset($_GET['car']))?$_GET['car']:((isset($write['ca_name']))?$write['ca_name']:'');

위 코드를 더 쉽게 할 수 있을까요?

|

답변 2개 / 댓글 3개

채택된 답변
+20 포인트
Copy
$ca_name = $_GET['car'] ?? $write['ca_name'] ?? '';

답변에 대한 댓글 2개

이거 진짜 되는거에요?
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_oper_null_coalescing
https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce
Copy
$ca_name = '';
if (isset($_GET['car']) == true) {
    $ca_name = $_GET['car'];
} else if (isset($write['ca_name']) == true) {
    $ca_name = $write['ca_name'];
}

답변에 대한 댓글 1개

Check another guy's answer. It will help you, too.

답변을 작성하려면 로그인이 필요합니다.