Understanding Notices Promoted to Warnings

There are a number of situations that are considered less critical to the stability of the PHP engine during runtime that were underrated in versions of PHP prior to PHP 7. Unfortunately, it was customary for new (or perhaps lazy!) PHP developers to simply ignore Notices in their rush to get their code into production.

PHP standards have dramatically tightened over the years, leading the PHP core team to upgrade certain error conditions from Notice to Warning. Neither error reporting level will cause the code to stop working. However, it is felt by the PHP core team that the Notice-to-Warning promotion will make bad programming practices keenly visible. Warnings are much less likely to be ignored, ultimately leading to better code.

Here is a brief list of error conditions leading to a Notice being issued in earlier versions of PHP, where the same condition now generates a Warning in PHP 8:

  • Nonexistent object property access attempts

  • Nonexistent static property access attempts

  • Attempt to access an array element using a nonexistent key

  • Misusing a resource as an array offset

  • Ambiguous string offset cast

  • Nonexistent or uninitialized string offset

Get hands-on with 1400+ tech skills courses.