Getting Started with PHP

To embed PHP into HTML you must '<?php' to start the script and '?>' to to end it. PHP can be placed into any part of a web page, event before the opening '<html>' tag, however, this is generally for processing information rather than displaying it. 

The example below embeds some PHP into a paragraph to display the contents of a variable, which has been previously defined.

   $hello = "Hello world";
<!DOCTYPE html>

   <p><?php echo $hello; ?></p>


As with any programming or scripting language, it is good practice to include comments to make it easier to understand your code. You can either use single or multi-line comments as shown below.

   // This is a single line comment.

   /* This
      comment */