Page 1 of 1

Why use @ in PHP functions?

Posted: Fri Jun 22, 2007 10:39 pm
by zanypaagal
Hi,

I am a newbie to PHP. I want to know why do we use @ in PHP specially with functions such as:

@mysql_pconnect
@move_uploaded_file
.......

Please let me know.

Thanks

Posted: Fri Jun 22, 2007 10:42 pm
by superdezign
Suppress error messages.

Posted: Fri Jun 22, 2007 10:47 pm
by zanypaagal
superdezign wrote:Suppress error messages.
Thanks for your help. I have also found out that some of the functions (as mentioned) do not work on some servers unless used with @. Why so?

Posted: Fri Jun 22, 2007 10:50 pm
by Benjamin
What makes you say that? @ is bad. You getting headers already sent messages or something?

Posted: Fri Jun 22, 2007 10:56 pm
by zanypaagal
astions wrote:What makes you say that? @ is bad. You getting headers already sent messages or something?
I'm not getting such messages. While working with PHP codes on some servers, I found that the function would not execute or give the desired result unless prefixed with @. I want to know why does this happen?

Thanks

Posted: Fri Jun 22, 2007 10:58 pm
by John Cartwright
The only thing is does is suppress php from directly outputting an error message, typically when you want to handle the error yourself in a more controlled way. In no way does it alter the execution of the function.