Suppressing errors in this way is useful, but not for your example because there are more traditional ways to check for those potential errors.
I use it sometimes, but normally for IO operations. For example.
$sample = 'sample.txt';
if (!file_exists($sample)) {
throw new FileNotFoundException($sample);
}
if (!$fp = @fopen('sample.txt', 'r')) {
throw new IOException($sample, error_get_last()['message']);
}
The exceptions in this are classes I would have created. The goal is to open a file for reading, first I need to check the file exists, thats easy, if it doesn't I can throw a relevant error.
Next is to open the file. Well this is a nothing or all operation and there could be a multitude of reasons why it won't work (permissions for example).
I want to handle the the problem if there is one (in this case by catching an exception) so I suppress the error (because I don't want users to see it), but I do want to know what happened, so I catch the exception, log the message somewhere and redirect the user somewhere else.
I use @
because I don't know what the error might be and because depending on the PHP configuration it will always trigger an error regardless of what you do with the return value.
Don't use it for something like getting an array value by index, because there are very few types of problems with this and they can all be checked for before starting the operation.