Php - Error



See error_reporting

ini_set('display_errors', true);
ini_set('html_errors', false);


The message level is set on a binary system number where each value can be seen at errorfunc.constants

Example: If the first bit is set to 1, we got all messages with an E_ERROR level.

Level Description Bit Integer
E_ERROR First Bit 0000000000000001 1
E_WARNING Second Bit 0000000000000010 2
E_PARSE Third Bit 0000000000000100 4
E_NOTICE Fourth Bit 0000000000001000 8
and so on until ….
E_ALL All bit ‭0111111111111111‬ 32767

You may then use bitwise operator to set each bit and choses the level of the messages that you want to report.



How to test if you need to show a message

if (!($errorLevelNumber & \error_reporting())) {
    return false; // Don't show
} else {
   return false; // Show

How to known which level is set

  • And check the bits:
    • 0 means the message will not be shown at this level
    • 1 means the message will be shown at this level

Example with the value 32,759, the 4th bit is unset and that means that the E_NOTICE message are not shown.



\trigger_error('foo', \E_USER_NOTICE);
\trigger_error('foo', \E_USER_DEPRECATED);
\trigger_error('foo', \E_USER_WARNING);
\trigger_error('foo', \E_USER_ERROR);

Powered by ComboStrap