It looks like you’re trying to use the ternary operator for something it simply can’t do. It’s not really a shorthand if-else, although I can see why it might be thought of as such.
It’s not at all clear what your code is meant to do, whereas John’s code is clear that it’s an if clause.
This works (assuming you’re doing something like an echo or variable assignment that you didn’t show in the example), replacing the “in ↔ out PHP” stuff which IMHO tends to get messy even when it does “work”.