Datasheet
17
Chapter 1: Introduction to PHP and MySQL
When PHP is installed, the Web server is configured to expect certain file
extensions to contain PHP language statements. Often the extension is .php
or .phtml, but any extension can be used. When the Web server gets a
request for a file with the designated extension, it sends the HTML state-
ments as is, but PHP statements are processed by the PHP software before
they’re sent to the requester.
When PHP language statements are processed, only the output is sent by
the Web server to the Web browser. The PHP language statements are not
included in the output sent to the browser, so the PHP code is secure and
transparent to the user. For instance, in this simple PHP statement:
<?php echo “<p>Hello World</p>”; ?>
<?php is the PHP opening tag, and ?> is the closing tag. echo is a PHP
instruction that tells PHP to output the upcoming text. The PHP software pro-
cesses the PHP statement and outputs this:
<p>Hello World</p>
which is a regular HTML statement. This HTML statement is delivered to the
user’s browser. The browser interprets the statement as HTML code and
displays a Web page with one paragraph — Hello World. The PHP statement
is not delivered to the browser, so the user never sees any PHP statements.
PHP and the Web server must work closely together.
PHP is not integrated with all Web servers but does work with many of
the popular Web servers. PHP is developed as a project of the Apache
Software Foundation — thus, it works best with Apache. PHP also works with
Microsoft IIS/PWS, iPlanet (formerly Netscape Enterprise Server), and others.
Although PHP works with several Web servers, it works best with Apache.
If you can select or influence the selection of the Web server used in your
organization, select Apache. By itself, Apache is a good choice. It’s free, open
source, stable, and popular. It currently powers more than 60 percent of all
Web sites, according to the Web server survey at www.netcraft.com. It runs
on Windows, Linux, Mac OS, and most flavors of Unix.
MySQL and PHP, the Perfect Pair
MySQL and PHP are frequently used together. They’re often called the
dynamic duo. MySQL provides the database part, and PHP provides the appli-
cation part of your Web database application.
05_527580-ch01.indd 1705_527580-ch01.indd 17 11/3/09 8:50 PM11/3/09 8:50 PM