Solved

How to catch error codes when testing PHP or HTML code

Posted on 2015-01-21
4
243 Views
Last Modified: 2015-01-23
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 ?
0
Comment
Question by:Scott Johnston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 400 total points
ID: 40563437
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:

ini_set('display_errors',1); 
 error_reporting(E_ALL);

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.
0
 

Author Comment

by:Scott Johnston
ID: 40563456
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
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40563498
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.
https://developer.chrome.com/devtools
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 40563628
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question