What does the "@" sign do in front of a function?
What's the difference between @unlink and unlink?
"@" in front of a function
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
@ 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);
}
Last edited by Christopher on Mon Jan 08, 2007 5:02 pm, edited 1 time in total.
(#10850)