Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is @unlink a bad practice? [closed]

Tags:

php

I'm usually against using @ as it can cause lots of headaches. But look at this two examples:

a)

if(file_exists('file'))
    unlink('file');

.

b)

@unlink('file');

.

It sounds like b is causing less disk lookups, which is good for performance. So my question is: would option b cause me any problem or has any disavantages in relation to a?

like image 576
Hugo Mota Avatar asked Jan 09 '12 17:01

Hugo Mota


1 Answers

I would just go for the first one.

What if the file couldn't be deleted because of another reason than simply the fact that the file doesn't exist?

like image 128
PeeHaa Avatar answered Oct 24 '22 06:10

PeeHaa