I want to write this in one line if possible:
if ($some_var === true) {
$return .= $input;
} else {
echo $input;
}
Obviously I don't want this: if ($some_var === true) { $return.= $input; } else { echo $input; }
if ($some_var === true) { $return.= $input; } else { echo $input; }
if ($some_var === true) { $return.= $input; } else { echo $input; }
but a shorter version of it.
I looked at other answers but I only find the echo (expression)? true: false; statements. I don't want to echo on the true, only on the false.
$some_var = true;
$input = 'abc';
$return = '123';
echo ($some_var === true) ? ($return .= $input) : ($input);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.