PHP if shorthand and echo in one line - possible?

Wordpressor picture Wordpressor · Nov 27, 2013 · Viewed 70k times · Source

What's the best, preferred way of writing if shorthand one-liner such as:

expression ? $foo : $bar

Plot twist: I need to echo $foo or echo $bar. Any crazy tricks? :)

Answer

Dave picture Dave · Nov 27, 2013
<?=(expression) ? $foo : $bar?>

edit: here's a good read for you on the topic

edit: more to read