Dealing with Warnings That Are Now Errors
Learn about the warnings that are considered errors now in PHP 8.
In this lesson, we look at upgraded PHP 8 error handling pertaining to objects, arrays, and strings. We also examine situations where, in the past, PHP issued a Warning
but where PHP 8 now throws an Error
. It is critical that we become aware of any of the potential error situations addressed in this lesson. The reason is simple: if we fail to address the situations described in this lesson when our server is upgraded to PHP 8, our code will break.
Developers are often pressed for time. It could be that there’s a massive queue of new features or other changes that must be made. In other cases, resources have been pulled away to other projects, meaning fewer developers are available to perform maintenance. Warnings
are often ignored because the application continues to run, so many developers simply turn off the error display and hope for the best.
Over the years, mountains upon mountains of badly written code have accumulated. Unfortunately, the PHP community is now paying the price in the form of mysterious runtime errors that take hours to track down. By promoting to Error
certain dangerous practices previously only raising to a Warning
, bad coding practices quickly become apparent in PHP 8 because Errors
are fatal and cause the application to stop running.
Get hands-on with 1200+ tech skills courses.