views:

67

answers:

4

I am writing a PHP mail function and some examples have @mail(…) and others have just mail(…).

What is the difference and which one is best to use?

Cheers

+8  A: 

@ supresses all warnings/errors, which mail() function may throw.

It is not good practice to use "@", because you never know if something doesn't work and also it hits the performance of you PHP application too!

Laimoncijus
Brilliant :) That answered my question perfectly
Designer023
+2  A: 

I believe it's the same function but with error suppression

PHP: Error Control Operators - Manual

piddl0r
Cheers :D It seems that it is an error suppression
Designer023
+1  A: 

@mail means you are suppressing any errors that might occur while trying to send the email, see this SO question for more information: http://stackoverflow.com/questions/136899/ddg#138110

Kristoffer S Hansen
Cheers. That answers more of my questions. Thanks for the help
Designer023
A: 

Error suppression is resource-consuming operation. It is recommended to call functions without @ and use exceptions/error handling

I would normally use the non-suppressed functions, but I found the @mail in a site I have been maintaining and didn't want to mess with it too much.
Designer023