Membership
Main Menu
Forum Boards
Stats
- 20 tutorials
- 74,814 members
- 734,877 forum posts
- 13 blog posts
Tutorials
Debugging: A Beginner's guide
by Ben Smithers on Jun 9, 2008 5:47:39 PM
Views: 28914
Tutorial Summary
In no particular order, here are my tips for finding your errors:
- Make sure PHP is displaying errors
- Set your error reporting to E_ALL
- Remove error suppression
- Use a good editor
- Indent your code
- Use 'or trigger_error' statements with every query
- Echo out if you're having problems
- Check the previous lines for syntax errors
I should also say that my intention with this tutorial was to provide some general help for a beginner during the development stage. You should note that there are other, more graceful methods of handling errors (an error handling class with exceptions being the best route) in the long run. Even if you don't go the whole hog you should consider the following before your site goes live:
- Turning off display errors. Yeah, I know I told you to turn it on earlier, but that was to help you find the error to start with. Once your site is live, you don't want users seeing nasty error messages.
- Ensuring log_errors is turned on. This allows you to find out if any errors do occur after your site is live.
- Think about your error_reporting level. In PHP 6, E_STRICT errors will become apart of E_ALL. For more on this, see the manual.
Comments
1. philipolson on Jun 10, 2008 2:09:56 PM
2. Ben Smithers on Jun 10, 2008 5:13:00 PM
3. anthropos9 on Jun 10, 2008 6:55:58 PM
4. Daniel Egeberg on Jun 11, 2008 12:54:49 AM
5. Ben Smithers on Jun 11, 2008 1:40:02 AM
6. Daniel Egeberg on Jun 11, 2008 2:39:08 AM
7. Ben Smithers on Jun 11, 2008 7:22:07 AM
8. Stephen on Jun 15, 2008 8:31:49 PM
9. Ben Smithers on Jun 16, 2008 3:51:06 PM
10. Bleakers on Jun 19, 2008 8:51:48 AM
11. Daniel Egeberg on Jun 19, 2008 1:17:22 PM
12. Bleakers on Jun 20, 2008 6:40:16 AM
13. akitchin on Aug 21, 2008 6:12:02 PM
Login or register to post a comment.
