• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

How to catch error codes when testing PHP or HTML code

When writing some PHP scripts or HTML scripts I like to know what the mistake are when I test the script.  Is there any type of coding I can add to a PHP or HTML program that will tell me what line of code it stopped at ?
Scott Johnston
Scott Johnston
2 Solutions
Jason C. LevineNo oneCommented:
HTML is not script, it's a markup language. It will either display or not display depending on the magnitude of the error and the browser's ability to correct your bad markup (most browsers are pretty good at this).

If you open an HTML page in any decent text editor that does syntax highlighting (Programmer's Notepad, Notepad++, Sublime) it will become pretty obvious where your mistakes are if the syntax is off.

For PHP, different story.  Add the following code to the top of your PHP scripts:


Open in new window

That should force the script to send any errors to the browser for your reading enjoyment.  Just make sure to remove those or comment them out before deploying the script in a production environment.
Scott JohnstonSystems ConsultantAuthor Commented:
I use sublime and love it...
I testing a script for emailing info to customers.
This code help in debugging.
It worked great...I have a lot of work now.
Just to make sure the Error report starts of with NOTICE: ........................talks about what is wrong and what line number....

Thank you
Ray PaseurCommented:
You might want to learn about Google Chrome Dev Tools.  This will take you an entire day of your life and it will put you about a year ahead of other developers who have not chosen the power.  Use the power wisely.
Dave BaldwinFixer of ProblemsCommented:
For HTML and the HTML generated by PHP, there is the W3C Validator http://validator.w3.org/ which will tell you about HTML errors and non-standard syntax.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now