I am working with a previous developers code and a lot of his code hide errors with the @
One example being:
if(!file_exists($filename))
throw new Exception("file '$filename' does not exist.");
$xmlObject = @simplexml_load_file($filename);
if($xmlObject === false)
throw new Exception("Could not load '$filename' check syntax and file has read permission.");
I understand that using the @ hides errors but is this good practice or bad?
It’s bad. You should always check to make sure everything is legit. Developing good clean code will allow you to identify issues when something does go wrong. By using the @ it will suppress those errors which could be caused by something else entirely. You would never know and troubleshooting becomes that more difficult.
Taking your example above.
That person is already checking if the file exists. You could probably remove that @ symbol and change it up with try catch blocks.