Nate Weiner

This is an old archived post from my former blog The Idea Shower. It's where I cataloged my product explorations and releases, one of which ultimately became Pocket.

This post was published back in 2007. It may not function as originally intended or may be missing images.

Ternary Operator in PHP (and javascript)

August 31, 2007
$ternary = ‘Awesome’; print 'Does Ternany Rock? '; print ( ($ternany == ‘Awesome’)?(’Yea it sure does.’):(’No.’) );Outputs: Does Ternany Rock? Yea it sure does.
It’s a much more lightweight way of writing a simple if-statement with two outputs.

Where I learned about it: