PHP Tags


To write your php code, you need to wrap it inside PHP tags. You can think of php tags as a boundry line for php code on your page. Php tags are usually in a couple shape just like any html tags.

Php starting tag is <?php, while the ending tag is ?>

The standard way of writing php tags is

Some php code can also be written inside a <script> tag:

ASP style can also be used to write php code:

 A short way of writing php tags is:

In this php tutorial we will stick to standard way of writing php tags: <?php  …  ?>. This way we will be sure it will work on any server running the php interpreter.

In PHP we will be using different small element again and again, some of them are:

  • semicolons (;) : to end lines
  • normal brackets, or parenthesis ( ): most of the time represent a function.
  • square brackets [ ]: are for arrays
  • curly braces { }: define the block or body of a structure.

To read about PHP comments, click here.