Use Ternary Operators

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: 1 <?php $host = strlen($host) > 0 ? $host : htmlentities($host); ?> Oops! The author actually means to escape $host if the string length is greater than zero, but […]

Posted in Tips | 6 Comments »