PHP 5.4 中的 E_STRICT 和 E_ALL 有什么区别?
What is the difference between E_STRICT and E_ALL in PHP 5.4?
在PHP 5.4中,使用E_STRICT
和E_ALL
有什么区别?
两者一样吗?
在PHP 5.4中,使用E_STRICT和E_ALL.
有什么区别
嗯:
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).
一个例子:
<?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);
?>
A similar question answered on SO here as well.
E_ALL
将显示所有级别的错误,在 PHP 5.0 上引入的 E_STRICT
将显示 suggestion/notice 严格编码 standard/best 实践。由于 PHP 5.4 E_STRICT
包含在 E_ALL
.
基于 PHP 手册:
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.
在PHP 5.4中,使用E_STRICT
和E_ALL
有什么区别?
两者一样吗?
在PHP 5.4中,使用E_STRICT和E_ALL.
有什么区别嗯:
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).
一个例子:
<?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);
?>
A similar question answered on SO here as well.
E_ALL
将显示所有级别的错误,在 PHP 5.0 上引入的 E_STRICT
将显示 suggestion/notice 严格编码 standard/best 实践。由于 PHP 5.4 E_STRICT
包含在 E_ALL
.
基于 PHP 手册:
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.