mardi 20 octobre 2015

Suppress errors for if(file_exists)

I was wondering if suppressing warning for a method might ever be a better and shorter version of using an if or shorthand if statement like so:

if(file_exists('a/file/path/that/doesnt/exist.file')) {

    unlink('a/file/path/that/doesnt/exist.file');

}

Possible shorter version:

@unlink('a/file/path/that/doesnt/exist.file');

If we are definitely sure, that the only problem that could occur during the unlink method is a 'file missing/not found' situation, and not anything else(permission denied etc.), would it be okay to simply suppress the unlink function?

Aucun commentaire:

Enregistrer un commentaire