100 likes | 233 Views
Chapter 8. Error Handling and Debugging. Debugging. “ When you get frustrated, step away from the computer!”. Error Sources. HTML PHP Syntax Run-time Logical SQL MySQL. Debugging HTML. Layout is messed up. http://validator.w3.org /. Debugging PHP. Syntax errors & Run-time errors
E N D
Chapter 8 Error Handling and Debugging
Debugging • “When you get frustrated, step away from the computer!”
Error Sources • HTML • PHP • Syntax • Run-time • Logical • SQL • MySQL
Debugging HTML • Layout is messed up. • http://validator.w3.org/
Debugging PHP • Syntax errors & Run-time errors • Error messages • Logical errors • Hardest • echo variables
display_errors.php • Script 8.1 on page 248 • http://cscdb.nku.edu/csc301/frank/ch08/display_errors.php • See 3 on page 249 for explain of errors • ch08\display_errors.php • Turn off • ini_set(‘display_errors’, 0);
report_errors.php • Script 8.2 on page 251 • http://cscdb.nku.edu/csc301/frank/ch08/report_errors.php • ch08\report_errors.php
Error Report Levels • Table 8-1 on page 250 • E_ALL – all errors, warnings, and recommendations • E_ERROR – all fatal run-time errors • E_DEPRECATED – warnings about code that will not work in the future
Rule of Thumb • “you’ll want PHP to report on any kind of error while you’re developing a site but report no specific errors once the site goes live.”
handle_errors.php • Script 8.3 on page 254 • http://cscdb.nku.edu/csc301/frank/ch08/handle_errors.php • ch08\handle_errors.php