Just having issues with the syntax for this, is it possible?
echo '<li><a href="' .$item->url. '" ' .($item->target != '') ? "target=$item->target" : "". '>' .$item->post_title. '</a></li>';
I’m not sure where I should concatenate and how to echo the if statement result.
Operator precedence can be ugly, especially in PHP where the rules for the
?:operator don’t match most other languages (it is left-associative in PHP, and right-associative ~everywhere else, though this is unlikely to be your problem since you only use the operator once here).When in doubt, use parentheses to make your intent clear: