bannermuseum

When developed in 1994 , PHP stood for Personal Home Page. Later it was changed to Hypertext Preprocessor. The "pre" refers to how PHP handles information before it becomes HTML. Because PHP is a server-side technology, software must be available on your web server for you to use PHP. PHP can be thought of as "dynamic HTML pages" because content will vary based on the results of interpreting the script.

This script language and interpreter is freely available open source and used primarily on Linux Web servers. Because it's free and easy to use, it has become a popular alternative to Microsoft's Active Server Page (ASP) technology.

Why choose PHP over other tools for building dynamic websites? Many developers find PHP easiest to use. It's also free and cross-platform. It's become popular with both hobby and professional web designers, so there are many online materials to support its use.

The official website for PHP is located at http://www.php.net. You can also locate lots of great resources at http://www.zend.com.

readRead PHP at wikipedia for an overview of PHP

PHP Basics

A PHP script is embedded within a web page along with its HTML. Before the page is sent to a user that has requested it, the web server calls PHP to interpret and perform the operations called for in the PHP script.

In a couple paragraphs, I'll try to provide an overview of the basics. Keep in mind that PHP documents end with .php file extension. However some servers may require the .php3 or .phtml extension instead. You use tags just like XHML, but you use question marks within the start and end tags such as <?php and ?>. Also keep in mind that the scripts will only function on a PHP-enabled server.

Here's a quick way to test whether your ISP web server is PHP enabled. Create a simple document with the following text. Save it as practice.php. Upload it to your web server. Then, open your browser and try the file such as http://eduscapes.com/arch/enhance/practice.php.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text-html; charset=iso=8859-1" />
<title>Practice with PHP</title>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html>

If php is enabled, you should see something on your screen like the following graphic.

php in browser

Let's explore some basic PHP terminology.

Variables. You use variables as storage containers for data. You use a $ in front of a variable name. The name must be letters or begin with an underscore _. Do not use spaces. Variables are case sensitive. Stick to lower-case as a good habit or squish words together and capitalize the first character such as $LastName. Putting a number of things together is called a string. Enclose strings in single or double quotes. If you have a series of separate things, they are called an array. Variables might remind you of using a database and mail merge program.

Let's look at an example.

<?php

// My pet
$yourfirstname = "Annette";
$pet = "cat";
$petname = "Kelsey";

//Print pet information
print "$yourfirstname has a $pet named $petname.";

?>

Go the Pet page for the result. It's not very exciting, but imagine if you were accessing a pet hospital's website looking for a playmate for your cat! Okay, it's silly, but this is how websites like Amazon, eBay, and all the other database driven websites work.

Forms. Much of the power of PHP comes from the use of forms to collect information that can be stored and searched later. The skills you already have in creating forms in XHTML can be applied to developing forms here. You just add a PHP script that deals with the information that is generated.

The best way to learn PHP is to explore print and online resources. Also consider using Dreamweaver. PHP commands are already built in making it easy to use.

Databases. PHP is often used along with database server tools such as the open source software called MySQL

Learn More

There are many excellent books and websites available on this topic. You might wish to start with the following, easy-to-use texts:

Ullman, Larry (2004). PHP for the World Wide Web. Second Edition. Peachpit Press. ISBN 0-321-24565-2. This book also has a great companion website.

Ullman, Larry (2003). PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide . Peachpit Press. ISBN 0-321-18648-6

Another alternative is to right to Adobe and make use of their many great resources for ASP.NET and PHP. They also have some great manuals.

Other Resources

PHP: Land of Code

PHP Builder - Great for ideas

PHP Definition - Definition and background information

PHP Home - The offical website of PHP

PHP Tutorial - Great tutorial to learn the basics at W3 schools


| eduscapes | IUPUI Online Courses | Teacher Tap | 42explore | escrapbooking | About Us | Contact Us | ©2006-2011 Annette Lamb and Larry Johnson