简体   繁体   中英

What is the difference between the function calls “mail()” and “@mail()”?

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

@ 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!

It's the same function but with error suppression

PHP: Error Control Operators - Manual

@mail意味着您正在抑制尝试发送电子邮件时可能发生的任何错误,请参阅此SO问题以获取更多信息: 在PHP中使用@运算符抑制错误

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM