Question about the difference in function calls using '@'

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
calpha
Forum Newbie
Posts: 3
Joined: Mon Jun 09, 2003 1:14 am

Question about the difference in function calls using '@'

Post 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?
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

It supresses errors.
calpha
Forum Newbie
Posts: 3
Joined: Mon Jun 09, 2003 1:14 am

Post 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.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

move_uploaded_file returns a boolean, false or true.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post 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.
calpha
Forum Newbie
Posts: 3
Joined: Mon Jun 09, 2003 1:14 am

Post by calpha »

cool....thx a bunch guys. Now I know how to use "@".
RFairey
Forum Commoner
Posts: 52
Joined: Fri Jun 06, 2003 5:23 pm

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