Page 1 of 1

Question about the difference in function calls using '@'

Posted: Mon Jun 09, 2003 1:14 am
by calpha
Been coding php for a while, and am a self admitted hack----;)

I'm reviewing a mod for an Invision BBS, and have come across the code

Code: Select all

if (! @move_uploaded_file( $HTTP_POST_FILESї'file']ї'tmp_name'], $ibforums->varsї'd_download_dir'].$FILE_NAME) )
The variables don't matter, what I don't understand/have never seen before is the use of the @sign (the first character before the php move_uploaded_file)

What's the @ sign do?

Posted: Mon Jun 09, 2003 2:07 am
by qartis
It supresses errors.

Posted: Mon Jun 09, 2003 2:31 am
by calpha
ahhhhh.......so if you use the @ with move_uploaded_file then how do you detect if the file didn't copy????

thx for the reply btw.

Posted: Mon Jun 09, 2003 2:34 am
by patrikG
move_uploaded_file returns a boolean, false or true.

Posted: Mon Jun 09, 2003 3:32 am
by qartis
function() will still return a false or true depending on whether or not it executed properly - @ supresses errors that will be outputted directly to the user, like if you're fopen()ing a nonexistant file.

Posted: Mon Jun 09, 2003 3:35 am
by calpha
cool....thx a bunch guys. Now I know how to use "@".

Posted: Mon Jun 09, 2003 8:05 am
by RFairey
useful for my_sql_connect and things like that when you don't want error messages saying "using password: no" or somesuch being sent to the browser if a function fails.