Why use @ in PHP functions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zanypaagal
Forum Newbie
Posts: 3
Joined: Fri Jun 22, 2007 10:31 pm

Why use @ in PHP functions?

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Suppress error messages.
zanypaagal
Forum Newbie
Posts: 3
Joined: Fri Jun 22, 2007 10:31 pm

Post 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?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

What makes you say that? @ is bad. You getting headers already sent messages or something?
zanypaagal
Forum Newbie
Posts: 3
Joined: Fri Jun 22, 2007 10:31 pm

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Post Reply