In PHP 5.4, what is the difference between using E_STRICT
and E_ALL
?
Are both the same?
In PHP 5.4, what is the difference between using E_STRICT
and E_ALL
?
Are both the same?
In PHP 5.4, what is the difference between using E_STRICT and E_ALL.
Well:
5.4.0 E_STRICT became part of E_ALL.
5.3.0 E_DEPRECATED and E_USER_DEPRECATED introduced.
5.2.0 E_RECOVERABLE_ERROR introduced.
5.0.0 E_STRICT introduced (not part of E_ALL).
An Example:
<?php
// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
E_ALL
will show all level of error, E_STRICT
introduced on PHP 5.0 will show suggestion/notice of strict coding standard/best practice. Since PHP 5.4 E_STRICT
is been included in E_ALL
.
Based on PHP manual:
In PHP 5 a new error level E_STRICT is available. Prior to PHP 5.4.0 E_STRICT was not included within E_ALL, so you would have to explicitly enable this kind of error level in PHP < 5.4.0. Enabling E_STRICT during development has some benefits. STRICT messages provide suggestions that can help ensure the best interoperability and forward compatibility of your code. These messages may include things such as calling non-static methods statically, defining properties in a compatible class definition while defined in a used trait, and prior to PHP 5.3 some deprecated features would issue E_STRICT errors such as assigning objects by reference upon instantiation.
© 2022 - 2024 — McMap. All rights reserved.