Posts Tagged ‘Shortcut the else’

Shortcut the else in PHP

This tip accidentally stumbles upon a useful practice, which is to always initialize variables before you use them. Consider a conditional statement that determines whether a user is an administrator based on the username: <?php if (auth($username) == ‘admin’) { $admin = TRUE; } else { $admin = FALSE; } ?> This seems safe enough, [...]