Can we use @ in a PHP project?

Hello,
Can we use error suppression (@ operator behind function) in a PHP project? Would this be a reason for a reject?

It seems native PHP functions don’t throw error, so try-catch is not always a solution.

(I couldn’t find if there is a knowledgebase for PHP submissions. )

Thank you.

Error suppression (use “@”) should be avoided if possible as it doesn’t just suppress the error that you are trying to stop, but will also suppress errors that you didn’t predict would ever occur. This will make debugging a nightmare.

if you use “@” to suppress errors from a certain function and either it isn’t available or has been mistyped, the script will die right there with no indication as to why.

as far I know for this reviewer will give soft reject to fix it.

2 Likes

@ does exist for good reasons though and can be used where appropriate, like with ini_set.

2 Likes

Some built-in functions don’t throw error. As an example, exif_read_data:
https://www.php.net/manual/en/function.exif-read-data.php

In stackoverflow it’s suggested to use this function with @.
This function has a problem with some JPG files, I don’t exactly know why.

1 Like