The benefit of the ternary operator is debatable (there’s only one, by the way). Here is a line of code from an audit we performed recently:
<?<a title="See also PHP - Checking Exceptions speed" href="http://www.whileifblog.com/2012/05/12/php-checking-exceptions-speed/">php</a> $host = strlen($host) > 0 ? $host : htmlentities($host); ?>
The ternary operator may be fine for one-liners, prototypes, and templates, but we strongly believe that an ordinary conditional statement is almost always better. PHP is descriptive and verbose. We think code should be, too.
