|
Php Debugging Tips
- Be patient and read all error messages carefully. The description often
explains what the issue is and suggests what can be done to fix it.
- When dealing with syntax errors, check the line above the one specified
in the error message. Look for misspellings and extra or missing parenthesis,
braces, semicolons, etc.
- Indent your code to improve readability, and use a code editor with
syntax highlighting.
- If your code is giving you unexpected results, you probably have a logic issue.
Go through your code line by line checking for logic errors. These sort of errors
can be the toughest to catch because you won’t receive any error messages.
- Use echo and print_r() to check the values of your variables at various points
in your code.
- Use die() to halt you program’s execution at specific points in your code. (This
is best used with a combination of echo or print_r() functions.)
- Do a web search. Others may have run into the same issue you are encountering
and may have posted the solution.
- Have someone else look at your code. Staring at your own code for too long may
mean you miss obvious issues. If you don’t have anyone who knows PHP nearby,
consider posting your code on a web forum.
|
© Advanced Web Core. All rights reserved