Creating a PHP Page

PHP scripts can be either imbedded within standard HTML or be used to generate an HTML page entirely. Code written in PHP is wrapped with the <?php and ?> tags. On typical web hosts, PHP documents must end with the file extension ".php".

Note: The "\n" at the end of each line is a symbol which denotes a new line. It isn't required, but it makes the source code for the resulting HTML document more readable.

Example of PHP embedded within HTML:

<title>Embedded PHP</title>
  echo "Hello world!\n";

Example of HTML page generated with PHP:

  echo "<html>\n";
  echo "<head>\n";
  echo "<title>PHP Generated HTML</title>\n";
  echo "</head>\n";
  echo "<body>\n";
  echo "Hello world!\n";
  echo "</body>\n";
  echo "</html>\n";

<-- Previous   Next -->