PHP Syntax



Prev. Page
Index Page
Next Page
  • PHP code is bounded in HTML code with <?php and ?> brackets.
  • Possible alternatives are: <% and %> (if enabled in the PHP configuration file), or <script language="PHP"> and <script> tags. Since these are not guaranteed to be set on different servers, it is best to stick to the standard.
  • If a quoted string needs to include a quotation mark, precede it with a backslash (e.g. "He said, \"Yes, I do.\"")
  • There are a few ways to create comments in your PHP code:
    • Precede the comment with two forward slashes (//). Everything up to the end-of-line character will be considered a comment.
    • Precede the comment with the pound sign (#). Treated the same as two slashes.
    • Put the comment between /* and */ character combinations. Be careful not to nest these.
  • PHP Statements are separated from each other by semicolons. The standard practice is to place a semicolon at the end of each line of PHP code but the new line character is not necessary to the PHP interpreter.


Prev. Page
Index Page
Next Page

Copyright © 2003
Henry H. Hartley
All Rights Reserved