Hacker News new | ask | show | jobs
by 1SaltwaterC 4848 days ago
Due to the "PHP beauty", ! $string isn't equivalent for $string == ''. In this case it is better due to the logical evaluation clusterfuck that PHP does. Example: passing an empty array() as $string bypasses the if, while ! $string is sane enough, but the bang operator fails with "0" which is a valid string that "happens" to evaluate to false. I know these are edge cases, but can lead to funny bugs. Not so funny for those who debug that.