PHP Function Error_Get_Last
For PHP, the php function error_get_last gets information about the last error that occured. It can be helpful when working with debugging. It can help in tracing where the errors have occurred and when they occurred in your application.
Error handling is a necessary part of developing any web application. PHP allows you to handle errors in several ways with the exceptions, custom error handler, or by logging. Errors can be expected or unexpected and if not handled properly may cause a website to break or produce an error for the site visitor.
Many people add error reporting operators to their code to report errors to the screen but that is a bad practice as it interferes with the ability to correctly handle errors. A better practice is to let PHP generate and report the errors, ideally in an ini setting or.htaccess file, and then configure it to direct those errors appropriately. For example, on a dev server they should be shown on-screen and for production sites it may be more appropriate to log them.
In addition to the error_get_last() function, php provides a function called error_log() that allows you to log all errors into a file defined in the configuration settings of the web server. A popular use case is to log all exceptions that have occurred as the result of trying to set a handler for them. The logger function also allows you to see the errors in an associative array, which can be very useful for troubleshooting.