Chapter 3
Debugging PHP Code
IN THIS CHAPTER
Setting up PHP for debugging
Examining the PHP error log
Outputting variable values with echo and print
Making good use of print_r()
Getting to know var_dump()
The most effective debugging tool is still careful thought, coupled with judiciously placed print statements.
— BRIAN KERNIGHAN
Debugging — the art, science, and (sometimes) magic of finding and correcting programming errors — is a vital part of all web development. Why? Because no one — not even the nerdiest and most experienced of coders — can write anything moderately complex without introducing an error (or, more likely, a half dozen errors). Programming just works that way. Don’t ask me why because I really have no idea. It just does. So, when some code doesn’t work the first time (or even the tenth time), it doesn’t mean you’re a lousy coder. It just means you’re normal. Believe me, it happens to absolutely everyone who codes.
JavaScript code runs inside the browser, so debugging ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access