Part 2: PHP Syntax and Errors


  1. In a Linux context, does capitalization matter?
  2. Yes, it is case sensitive. For example, Test.php, TEST.php, and test.php are three separate files in Linux.

  3. What are the basic attributes of PHP syntax?
  4. PHP must begin with <?php and end with ?> enclosing the PHP code. Any quotation marks used must open and close - there must be a pair of them, and they must be of matching styles (both double quotations or both single quotation marks). Finally, each php statement must end with a semicolon (;), which is the equivalent to a period at the end of a statement in plain English.

  5. Discuss one of the PHP error handling techniques that Eli presents.
  6. If there is an error on line two in the coding, the PHP will display and describe an error and cite the line at which it thinks the error has occurred.

  7. What is the difference between printing text and printing HTML?
  8. HTML must be explicited instructed that text must appear on separate lines, otherwise it will simply string it all together. For example, if you were to intending to display plain text as

    "Hello

    World"

    but wrote in your code print "Hello"; on one line and print "World"; on another line, the text would be output as "HelloWorld" all together on one line.

  9. What happens if you add a PHP script to a HTML page and you don't change the file type to .php from .html?
  10. The browser will be expecting to read HTML script, and therefore may not interpret the code correctly. "Hello World" written on two lines in PHP may not display the same in an HTML browser, because it lacks the appropriate HTML tags.

notepad++ Example Program

The link above is the sample code created with Eli's demonstration of PHP syntax and errors. It is an extremely simple demonstration of a brief program printing "Hello World" in PHP.