13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

562 Chapter 26 Debugging<br />

Error Reporting Levels<br />

<strong>PHP</strong> allows you to set how fussy it should be with errors.You can modify what types of<br />

events generate messages. By default, <strong>PHP</strong> reports all errors other than notices.<br />

The error reporting level is assigned using a set of predefined constants, shown in<br />

Table 26.1.<br />

Table 26.1 Error Reporting Constants<br />

Value Name Meaning<br />

1 E_ERROR Report fatal errors at runtime<br />

2 E_WARNING Report nonfatal errors at runtime<br />

4 E_PARSE Report parse errors<br />

8 E_NOTICE Report notices, notifications that something you have<br />

done might be an error<br />

16 E_CORE_ERROR Report failures in the startup of the <strong>PHP</strong> engine<br />

32 E_CORE_WARNING Report nonfatal failures during the startup of the <strong>PHP</strong><br />

engine<br />

64 E_COMPILE_ERROR Report errors in compilation<br />

128 E_COMPILE_WARNING Report nonfatal errors in compilation<br />

256 E_USER_ERROR Report user-triggered errors<br />

512 E_USER_WARNING Report user-triggered warnings<br />

1024 E_USER_NOTICE Report user-triggered notices<br />

6143 E_ALL Report all errors <strong>and</strong> warnings except those reported in<br />

E_STRICT<br />

2048 E_STRICT Reports use of deprecated <strong>and</strong> unrecommended behavior;<br />

not included in E_ALL but very useful for code<br />

refactoring. Suggests changes for interoperability.<br />

4096 E_RECOVERABLE_ERROR Reports catchable fatal errors.<br />

Each constant represents a type of error that can be reported or ignored. If, for instance,<br />

you specify the error level as E_ERROR, only fatal errors will be reported.These constants<br />

can be combined using binary arithmetic, to produce different error levels.<br />

The default error level—report all errors other than notices—is specified as follows:<br />

E_ALL & ~E_NOTICE<br />

This expression consists of two of the predefined constants combined using bitwise<br />

arithmetic operators.The ampers<strong>and</strong> (&) is the bitwise AND operator <strong>and</strong> the tilde (~) is<br />

the bitwise NOT operator.This expression can be read as E_ALL AND NOT E_NOTICE.<br />

E_ALL itself is effectively a combination of all the other error types except for<br />

E_STRICT. It could be replaced by the other levels combined together using the bitwise<br />

OR operator (|):

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!