First we have to see types of errors in PHP:
Notices: These are non-critical errors which PHP encounters while running a script. For example, a variable accessibility before it is declared.
Warnings: The are more serious errors. For example, using include()without the existence of the file.
Fatal Errors: These errors are critical errors. For example, creating an object of a non-existent class. These errors terminate the script’s execution immediately. These are intimated to the users.
Now, the process of Catching these 3 types of errors
//Setting for the PHP Error Handler
set_error_handler( call_back function or class );
//Setting for the PHP Exceptions Error Handler
set_exception_handler(call_back function or class);
//Setting for the PHP Fatal Error
register_shutdown_function(call_back function or class);
Whatever the function or class is described by user for tracing the error the following command is used:
$debug = debug_backtrace();
print_r($debug);
If you print the debug then it will show you the running process and file name, line number of the error.