Join Jon Peck for an in-depth discussion in this video Triggering and repairing PHP errors, part of Debugging PHP: Advanced Techniques.
- View Offline
I'm going to demonstrate a number of different kinds of errors then repair each of them.…As I will be removing each test code when it's fixed, I will provide the code …in a separate exercise file.…The first kind of error I will demonstrate is E_ERROR.…E_ERROR example where I will intentionally run out of memory.…This is a fatal run time error that cannot be recovered from, …halting script execution and resulting in a crash.…I'll start by setting the memory limit to 1 kilobyte, ini_set ('memory_limit', '1K');…then I'll create a giant object by casting an array containing the numbers of 0 to 1,000 …as an object, var_dump ((object) range (0, 1000)), save then go to the browser and refresh.…
The fatal error will be displayed indicating that the system ran out of memory.…I'll return to the IDE and remove the artificially low memory limit, save, then try again.…This time the contents of the object are rendered correctly and the script does not crash.…Depending on the context of a script, it may make sense to increase the memory limit …
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