Join Jon Peck for an in-depth discussion in this video Gracefully handling fatal errors, part of Debugging PHP: Advanced Techniques.
- View Offline
While developers strive to write fault tolerant and problem-free code,…inevitably fatal errors and crashes do occur.…Rather than just presenting a user with a blank screen or interrupted output,…it's possible to programmatically execute a function just before …a PHP completely shutsdown using the PHP function register_shutdown_function.…As these functions execute during shutdown, typically there is little context …as PHP has already been cleaning up.…I've heard this described as writing a note after falling from a cliff.…
However, the function error_get_last will still work in this context …and will provide the line, file, error type and message as an associative array.…I'm going to demonstrate how to register a custom shutdown function …that will notify both the user and the administrator of the problem, but with the caveat of …this will not work if the file containing the register shutdown function has a parse error.…In the IDE, I'm going to start by registering the shutdown function …just after the block of ini_sets.…
This course covers installation of Xdebug on Apache as well as working with the NetBeans IDE (integrated development environment). Jon then introduces native web browser developer tools for Firefox and Chrome, and demonstrates browser independent web debugging tools. Best practices for debugging and profiling web application failures and performance issues are also covered.
- Configuring PHP error reporting
- Logging errors to file
- Gracefully handling fatal errors
- Installing Xdebug
- Understanding the principles of remote debugging
- Remote debugging with NetBeans
- Extending your browser with Firebug, FirePHP, or ChromePHP