PHP102

From mi-linux
Revision as of 12:37, 19 January 2007 by In6480 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

I've got my first file working, what's next?

As you know from CP1082 (HTML), writing valid HTML is critical to the success of a website - this is no different when writing PHP.

  • PHP can output HTML

For the vast majority of what you want to accomplish with PHP, you will likely what to output some information in the form of a webpage. Webpages need to consist of valid HTML, so PHP needs to output VALID HTML. We'll continue to use Transitional HTML 4.01 unless you feel confident enough to attempt the Strict version - either will be valid for assessments on CP1079.

First VALID PHP/HTML page

1. Open your preferred editor

2. Code the following exactly - DO NOT CUT AND PASTE - you will not learn by just pasting this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

 <HTML lang="en">
   <HEAD>
     <META http-equiv="Content-Type" content="text/html;charset=UTF-8">
     <TITLE>My First Valid HTML/PHP page</TITLE>
   </HEAD>
   <BODY>
 <?
   $name="MyName";
   echo "Hello - I am ".$name;
 ?>
   </BODY>
 </HTML>