It is very confusing; in fact, it's broken. You're putting all that HTML in a variable and then trying to echo "checked" instead of putting it in the variable as well - which is what I assume you're wanting to do.
This syntax is bad:
". if
if doesn't return a string, or anything that can be made into a string, or anything at all in fact, so after reading the . and expecting something it can use as a string, it falls over when it sees the if.
Replace the whole if(){} thing with a conditional operator:
($checked ?" checked='true'" : "")
That's probably what you intended.
Oh, and don't forget to put the stuff that follows in a string and join it to the rest with ..