PHP Error Suppression Symbol

Have you ever seen a PHP script where a line is prefaced with a “@” symbol? Ever wonder what it was for? The at symbol in PHP is the error suppression operator. Any expression with you use it with will never throw an error, even if it fails entirely. It works with any expression (function calls, variables, etc) but does not work for things like if/else statements or function definitions.

It’s often used with the mail() function when you want to send a notification email, but don’t care if it goes through or not, so long as the script doesn’t fail catastrophically.

@mail($to, $subject, $message, $headers);

It could also be used in a pinch to include() a file only if it actually exists at a certain path, though you would be better served using file_exists().