Debugging

It is possible that even with this tiny bit of PHP, you got an error message. Debugging in programming means to find errors with your scripts and fix them.  When starting out with PHP we may have a lot of errors. Luckily, many of the errors are common ones that we can easily check for and fix if we know the right things to look for.

Checking For Opening and Closing Tags

Remember that all of our PHP must begin with <?php and close with ?>.  If your page does not display correctly, try checking for this.

(In addition to closing the PHP block of code, we need to make sure that all of our html tags open and close properly.  While this will not likely cause an error, it will make things look weird.) 

No Spaces

PHP does allow spaces, they just have to come in the right places.

Spaces CAN NOT appear in the following places:

  1. Between the < and the ? or the ? and the php in the <?php
  2. Between the ? and the > in the ?> at the end of the PHP code block.
  3. Between the $ and variable name in a variable declaration like $varName

Spaces can appear in similar places that they appear in html.

Case Sensitivity

PHP is case sensitive. That means that you cannot exchange an upper case letter for a lower case letter. For example, you must use echo, not Echo, ECHO, or eChO.
INDEX, What do you Need?, Hello World: the first example, Syntax, Debugging, Self-Study Questions
Next lesson: Variables in PHPMAIN INDEX
EXAMPLES INDEX

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Debugging