Contact me:

Email

Return to Eli-PHP Tutorials

PHP Programming Part 2: PHP Syntax and Errors


1. In a Linux context, does capitalization matter?
Yes, capitalization is important in the Linux context. TEST.php and test.php are different files in the Linux context. This is important to keep in mind, since the majority of webservers are Linux servers.

2. What are the basic attributes of PHP syntax?
Three basic attributes of PHP syntax that Eli mentions are that:
  • All php code is enclosed between the tags. The interpreter then reads and interprets the code contained in between those tags.
  • Anything opened must also be closed, for instance strings are contained between two quotation marks ““.
  • Php commands are ended with semicolons ‘;’, which are the equivalent of a period that ends an English sentence.

3. Discuss one of the PHP error handling techniques that Eli presents
PHP normally outputs an error and tells you the file and more-or-less gives the line number for where the error is present in the code. Eli recommends Notepad++ because it numbers the lines for you, making it relatively easy to find where the error occurs.

4. What is the difference between printing text and printing HTML?
The difference between printing text and printing HTML is that the source file will read the text formatting while the web browser is reading the HTML. This creates a common error when using the \n tag in php, which prints a new line in the source file or an enter in the text editor. When viewing the same command in the web browser, those changes won’t be seen because it is expecting an html tag, such as < br > for the new line to be displayed.

5. What happens if you add a PHP script to a HTML page and you don’t change the file type to .php from .html?
A Linux file server will generally be able to read the PHP script, regardless of file association. However it is good practice to rename it as the programmer, so that you yourself will remember that it contains a PHP script.