HTML and CSS Reference
In-Depth Information
Two of these methods involve setting up a server on your computer, and the third depends on
having a hosting service. h e easiest thing to do is to sign up with a hosting service with PHP.
h en you just load your PHP i les as you would a Web page. A hosting service that has been
tested extensively and is reasonably priced is at
www.jtl.net
. (h e Linux minimum service
is all you need.)
If you want to install PHP on your computer do the following:
Windows only:
Go to
http://windows.php.net/download
and download the
latest stable version of PHP5. (You'll i nd “What version do I choose?” in the let column
to help you choose what you need for your system.) You'll also need to install an Apache
server; you can get one free from www.apache.org.
Macintosh only:
Go to
http://foundationphp.com/tutorials/php_
leopard.php
and follow the instructions for accessing the PHP on your system.
(Be
very
careful because you're going to be using the built-in Terminal in your Mac
and you'll be changing some key i les.) h is Web site shows you how to set up both
PHP and your built-in Apache server.
h e easiest method for all users:
If you want to download and install everything at once
(PHP, Apache server, and a MySQL database) for your Mac go to
www.mamp.info/en/
index.html
and for Windows go to
www.wampserver.com/en
. h is is the easiest
way to set up an actual database on your computer.
Setting up PHP and Apache can be awkward, but once it's set up, you don't have to do it again.
If you use the all-in-one method (the last one listed above), you can get the MySQL server
with which you can set up a database on your computer.
327
TESTING PHP
Once you have your system set up, whether it's on your computer or a hosting service, enter
the following program and test it:
<!
DOCTYPE HTML
>
<
html
>
<
head
>
<?php
print phpinfo();
?>
<
meta
http-equiv
=
”Content-Type”
content
=
”text/html; charset=UTF-8”
>
<
title
>
Test PHP
</
title
>
</
head
>
<
body
>
</
body
</
html
>
Save the program as
First.php
and place the i le in your Apache root folder. For example,
the following path is a typical one for Windows:
c:/Program File/apache Groub/
apache/htdocs/php
. h e added folder, php, is where to put your
First.php
. On a Mac,