Home >Backend Development >PHP Tutorial >php error_reporting() sets the error reporting level

php error_reporting() sets the error reporting level

WBOY
WBOYOriginal
2016-07-25 08:51:23995browse
  1. * For now, avoid warnings of E_STRICT mode
  2. * (this must be done before function definitions)
  3. */
  4. if (defined('E_STRICT')) {
  5. $old_error_reporting = error_reporting(0);
  6. if ($old_error_reporting & E_STRICT) {
  7. error_reporting($old_error_reporting ^ E_STRICT);
  8. } else {
  9. error_reporting($old_error_reporting);
  10. }
  11. unset($old_error_reporting);
Copy code

Common ones are as follows:

  1. // Turn off all error reporting; Turn off all errors

  2. error_reporting(0);

  3. // Report simple running errors; Report a simple running errors Running errors

  4. error_reporting(E_ERROR | E_WARNING | E_PARSE);

  5. // Reporting E_NOTICE can be good too (to report uninitialized

  6. // variables or catch variable name misspellings …); including reporting some uninitialized
  7. // variables or catch variable name misspellings …); Initialized variables or catching typos in variable names

  8. error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

  9. // Report all errors except E_NOTICE
  10. // This is the default value set in php .ini;Report all errors but not E_NOTICE

  11. error_reporting(E_ALL ^ ​​E_NOTICE);

  12. // Report all PHP errors (bitwise 63 may be used in PHP 3);Report all errors< ;/p>
  13. error_reporting(E_ALL);

  14. // Same as error_reporting(E_ALL); Same as above
  15. ini_set('error_reporting', E_ALL);

Copy code


🎜
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn