PHP Debugging Techniques




PHP Code
  1. <?
  2. ini_set('display_errors', 1);
  3. #temp. config your php.ini file for displaying errors
  4. #you may also edit your PHP.ini file and change this manually
  5.  
  6. error_reporting (E_ALL & ~E_NOTICE);
  7. #display errors
  8. ?>



Using error_reporting(); you can limit to what errors are reported.

Here is a list of reporting levels you can use, just code error_reporting(E_YOUR CHOICE); or if you want to use more than one use error_reporting(E_YOUR CHOICE & E_YOUR SECOND CHOICE);
etc, make sure you keep intact ini_set();


E_ALL ------------------- All errors
E_STRICT --------------- recommendations and E_ALL
E_ERROR --------------- Run-time errors (stops the execution of a script)
E_WARNING ------------ Run-time warnings (does not stop the execution)
E_PRASE ---------------- Prase Errors
E_NOTICE -------------- Notices (things that may or may not be problems with your script(s))
E_USER_ERROR -------- user-generated errors, used by the trigger_error(); function
E_USER_WARNINGS ---- same as above, just warnings
E_USER_NOTICE -------- Same again, just notices



If you are using E_ALL and dont want to report errors from other types of error reporting you can set it out like this
error_reporting(E_ALL & ~E_YOUR CHOICE);
~ means not.

hope this helps you out a bit, comments welcome, by the way, I ussually use E_ALL and if no errors I use E_STRICT.
chrism's Avatar
Author:
Views:
2,175
Rating:
There are currently no comments for this tutorial, login or register to leave one.