Short way for isset($a) ? $a : 'other'; [duplicate]
问题 This question already has answers here : How to make quick judgement and assignment without isset()? (4 answers) Closed 5 years ago . is there any shorter way for this in PHP? $b = isset($a) ? $a : 'other'; Like in JS $b = $a || 'other'; This does not realy look like a big thing, but when you have a large list of properties/keys to check, this becomes annoing. Thanks in advance :) 回答1: It is only possible if $a is guaranteed to exist. So in your case it would not be possible, because you seem