This is not the first time I encountered the problem. I have 2 variables in PHP of type string. When both of them are not empty I want something like this :
echo $var1 . ', ' . $var2;
My problem is that sometimes $var1
or $var2
could be empty so the coma is floating. I try this :
echo $var1 && $var2 ? $var1 . ', ' . $var2 : $var1 || $var2;
But when we are in the right condition, it send 1
. I hope the only way is not to test $var1 && $var2
then test $var1
and then test $var2
.
Thanks in advance,