Adding PHP to a Web Page
PHP is a programming scripting language that was first developed to generate HTML statements. Even programs written totally in PHP are ultimately displayed as ordinary HTML.
You can also write programs that are mostly HTML with just the occasional PHP statement. In this lesson you start with an HTML page and learn how to add PHP statements to it.
You are also introduced to the Case Study website. By the end of this book, you will have changed it from a static HTML/CSS site to a dynamic website. In this lesson you add the first bit of dynamic code.
Writing Your First PHP Page
You start with a simple HTML page that looks like Figure 2-1. The file is called lesson2a.html.
Here's the HTML for that page:
<html> <head> <title>Lesson 2a</title> </head> <body> <h1>Welcome</h1> <p>Today is Sep 27, 2011</p> </body> </html>
Now you turn this into a PHP page. All you do is change the file extension from .html to .php and it becomes a PHP file. When you call that in your browser it still looks just like Figure 2-1.
You can display standard HTML in your browser by entering the file path. An example of a file path is c:/xamppfiles/htdocs/lesson2a.html. With .php files, you enter the address that starts with the web root. An example of an address ...