Php string concatenation

now there is an ajax local refresh, which I want to write. Concatenate a string on the server and return it to the client, but it is illegal to write like this, how to write it better? I have tried. The ternary operator is fine, but it is not suitable for the current demand

echo "3333" . (if ($a==1) {
    $a
}else{$b});
Mar.23,2021

echo '3333'. ( ($a==1) ? $a : $b );

or:

echo '3333' . (function($a,$b){
   if ($a==1) {
    return $a
   }else{
    return $b
   }
}($a,$b));
Why does the

ternary operator not conform to the project? In fact, the ternary operator is very simple, otherwise you have to close or directly judge the result before splicing the output

Menu