E_STRICT Constant is Deprecated in PHP 8.4

E_STRICT Constant is Deprecated in PHP 8.4

The error_reporting function allows defining which PHP errors should be reported. PHP provides various error levels. The E_ALL constant represents all error types in PHP. It includes errors, warnings, notices and deprecations.

In production environments, it's common to exclude specific messages from logs using the bitwise NOT operator (~). For instance:

<?php

error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);

This code configures PHP to report all errors except deprecations and strict notices.

During PHP version upgrades, E_STRICT messages were reclassified as E_NOTICE. Because E_STRICT error level is no longer meaningful, the E_STRICT constant has been deprecated since PHP 8.4. To prevent the deprecation message, the previously presented code can be updated as follows:

<?php

error_reporting(E_ALL & ~E_DEPRECATED);

Leave a Comment

Cancel reply

Your email address will not be published.