unlink
doesn't throw exceptions, in generates errors. The proper way to do this is check that the file exists before trying to call unlink
on it. If you are merely worried about not having the errors output then you should just turn off display_errors
which you should always do in a production environment anyway. Then they will just be logged.
Do not suppress errors with the @
, its rarely advisable.
Can you be more descriptive about
@
Im not sure what you mean exactly. But the documentation is here. As far as why you don't want to use it... That is because then you never know that code isn't working or is problematic. Even if the code still works from a functional perspective it's still got an issue and that issue could potentially make something else completely not work at some point. If you never have the error you'll probably waste a lot of time debugging.
Its fine to change your log level or disable the display of errors, but you never want to completely suppress them.