How to Turn Off an On Screen Warning in PHP

PHP will display errors and warnings on the screen according to the level of error reporting defined in either the "php.ini" file or at runtime using the "error_reporting" function. Errors can be silenced or displayed selectively for notices, warnings and errors using the PHP predefined constants that are part of the PHP core. To turn off an on-screen warning in PHP, you need to set the appropriate error level at runtime.

Instructions

    • 1

      Determine the error level you want to suppress. For example, "E_WARNING" refers to all warning messages.

    • 2

      Insert a call to the "error_reporting" function into the code, either at the beginning of the file or prior to where you want to suppress on-screen warnings. Pass the constant for all errors, a carat, and the constant for all warnings to display all errors except warnings. For example, type:

      error_reporting(E_ALL ^ E_WARNING);

    • 3

      Call the "error_reporting" function again if you want to display on-screen warnings at a future point in the application. For example, type:

      error_reporting(E_ALL);

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured