FireworksColdFusionDreamweaverFreehandFlashMXHome
Latest New Content

Latest Free Content
View All
Free Content
Accessibility
CMX Learning Guides
Hosted by enterhost

Learning PHP - Part 1: A Gentle Introduction

By: Thomas Pletcher

Page 1 of 4

Set for printing

Next

According to Netcraft, PHP overtook Microsoft's ASP as the most popular web scripting language back in the spring of 2002. And PHP has continued its explosive growth ever since. Today, when the Apache web server powers nearly 70% of all sites on the Internet and its closest competitor, Microsoft's IIS, has a market share of just over 20%, PHP is far and away the most widely used server-side scripting language. Just what is it that makes PHP so popular?

PHP Advantages

PHP Is Free. PHP is free software. It is free in the sense of being free to use as you see fit, and also free in terms of cost. Moreover, PHP is open source — if you have the ability and inclination, you can examine the source code for the PHP interpreter (which is written in C) and even modify it. In fact, PHP is part of an open source "stack" of dynamic web publishing software known as LAMP, which stands for Linux, Apache, MySQL and either PHP, Perl or Python. While Perl and Python are also widely used, PHP is the language most commonly employed with the open source Apache web server and MySQL database. And you're not limited to running Apache-MySQL-PHP on Linux, though this is the most frequent scenario. There are also WAMP (Windows) and DAMP (Darwin, i.e., OS X) configurations.

Because you and/or your hosting provider don't have to pay licensing fees for PHP, Apache or MySQL, chances are you can operate your site less expensively than you could if you used a competing technology. In general, a LAMP site is far more cost-efficient to administer and maintain than any sort of dynamic site on Windows and IIS. I would argue that it's more reliable, too.

PHP Is Cross-Platform and Portable. As noted above, PHP (and Apache and MySQL) can run on almost anything. So if you develop with PHP, you have the benefit of unprecedented portability. For example, you can write your web applications on a Windows or OS X box and host on Linux. If for some reason you decide to move your PHP site to a Windows or OS X server down the road, you can do that without the need to change your code. This portability represents yet another kind of freedom you don't get with competing technologies.

PHP is generally used with the Apache web server, but it will also work with IIS or any other web server that supports the CGI standard. Similarly, PHP is commonly used with the MySQL database, but it also works just fine with PostgreSQL, Oracle, Microsoft SQL Server and many others.

PHP Was Built for the Web. PHP was created from the ground up as a web programming language. Many tasks — such as accessing form submissions and talking to a database — are easier in PHP as a result. And PHP scales well: its more complex capabilities such as object-oriented programming, XML processing and dynamic image generation are there when you need them, but stay out of the way when you don't. So in the beginning, while you're learning to use PHP, you can concentrate on the basics of handling user input and displaying output.

What You Need

To start learning PHP, your first step should be to install it. While detailed installation instructions are beyond the scope of this article, such instructions are not hard to come by — there are a number of articles here at CMX that detail the process, and some of these articles are free.

I recommend you install PHP 5. Although PHP 4 is still more widespread among hosting providers, this will gradually change; you may as well learn PHP using the latest version. The practice code you'll be writing should work in either version (I'll let you know if it doesn't). I also recommend you install the Apache web server, regardless of which platform you develop on, and install PHP as an Apache module (rather than installing the CGI version). Both the Apache and PHP sites offer additional installation instructions. Finally, you need to install MySQL. Again, you should find plenty of documentation on the MySQL site.

I think you'll find a couple of good books to be indispensable in learning PHP as well, so I'll recommend some here. PHP and MySQL Web Development, by Luke Welling and Laura Thomson (Sams, 3rd Edition, 2004) is excellent. The original 2001 edition served as my introduction to PHP; this new 3rd edition has coverage of both PHP 5 and the forthcoming MySQL 5. Learning PHP 5 by David Sklar (O'Reilly, 2004) is also very good, and quite accessible. Both books are available from Amazon and elsewhere, and both books have detailed installation instructions.

Page 1 of 4 1 2 3 4 Next


download
Download Support Files


Keywords
PHP, PHP 5, MySQL