0

I have seen the mail function preceded with an @ symbol. I have tried it in my code and I cannot see what difference it makes.

I have searched Google and the PHP documentation and I have not been able to find an explanation for this @ symbol.

Would someone kindly point me in th right direction please?

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by slyme
0

It is used to suppress errors. Even if function fails, it continues execution. But we should avoid using it, let the error shown and fix it.

0

Also if you want to check whether the mail sent commands you can stored in a variable of mail function with the @ symbol

$mail_sent = @mail( $to, $subject, $message, $headers ); 
echo $mail_sent ? "Mail sent" : "Mail failed";

or

if (mail( $to, $subject, $message, $headers ))
   echo "Mail sent";
else
   echo "Mail failed";

Edited by rajarajan07: n/a

0

Thanks guys ... I asked the question out of curiosity and your answers have made me realise that this is really quite relevent to the code I'm having problems with.

Thank you very much,

Simon.

Edited by slyme: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.