Page 1 of 1

"@" in front of a function

Posted: Mon Jan 08, 2007 4:53 pm
by methos
What does the "@" sign do in front of a function?

What's the difference between @unlink and unlink?

Posted: Mon Jan 08, 2007 4:57 pm
by Christopher
@ suppresses error messages, so if unlink gave an error (e.g. path does not exist, or not permission to delete) the @unlink would tell PHP not to display the error. In general it is considered bad form to use @ because if you expect that a error could occur then you should do proper checks for the error conditions. For example:

Code: Select all

if (file_exists($fileame) && is_writable($filename)) {
     unlink($filename);
}

Posted: Mon Jan 08, 2007 4:59 pm
by Luke