Handling the @ error control operator
For years and years, many PHP developers have used the @
error control operator to mask errors. This was especially true when using unreliable PHP libraries with badly written code. Unfortunately, the net effect of this usage only serves to propagate bad code!
Many PHP developers are exercising wishful thinking, believing that when they use the @
operator to prevent errors from being displayed, this makes it seem as if the problem has magically gone away! Trust me when I say this: it hasn't! In this section, we first examine traditional use of the @
operator, after which we examine @
operator changes in PHP 8.
Tip
For more information on traditional @
operator syntax and usage, have a look at this documentation reference page: https://www.php.net/manual/en/language.operators.errorcontrol.php.
@ operator usage
Before presenting a code example, once again it's extremely important to emphasize that we are not promoting the...