jump to content

Next Previous Contents

1. Introduction

PHP is a tool that lets you create dynamic web pages. PHP-enabled web pages are treated just like regular HTML pages and you can create and edit them the same way you normally create regular HTML pages.

PHP means, PHP: Hypertext Preprocessor

PHP costs $0. You can download it from PHP site at www.php.netexternal link . The license is GNU Public License (GPL), the same license under which popular software like Linux, Emacs etc are released. You have complete access to the source code and if you want to, you can add your own features to PHP.

PHP is available for most Unix platforms, GNU/Linux and Microsoft Windows(TM). How to install PHP in your Windows(TM) PC or Unix machine is well documented at the PHP site. It is quite easy to install.

PHP is also Year2000 compliant, if your machine is!

1.1 History

Three years ago, Rasmus Lerdorf, created PHP as Personal Home Page Tools to manage his online resume. It was a very simple language. People noticed it and started making suggestions to extend it. Many people contributed and with the source code available freely, it became a very feature-rich language. And it continues to grow.

PHP, though easy to learn, was slower when compared to mod_perl (perl embedded into webserver) scripts. Now, there is a new engine called Zend which is almost as fast as mod_perl and PHP4 will utilize Zend engine completely. PHP4 is still in beta. Andi Gutmans and Zeev Suraski are the primary authors of Zend. Visit the Zend site at www.zend.comexternal link .

From a personal project, PHP usage has shot up quickly. Netcraft reports that in October 1999, 931122 Domains and 321128 IP Addresses deliver pages created by PHP.

1.2 Advantages of PHP

There are lots of advantages of using PHP. Some disadvantages that come to mind are the facts that being a open source project, so far no commercial support is available, and the relatively slow speed of execution of PHP (prior to version 4). However, the mailing lists for PHP are extremely useful and unless you are running a site that is as popular as Yahoo! or Amazon.com, you probably will not notice the difference in speed at all. I haven't! Let us see the advantages now.

Learning Curve

Personally, I love PHP's very easy learning curve. Unlike Java or Perl, you just don't need to sink into 100's of pages of documentation to write a program which does something useful. With just a few basic syntax and language features, you can be productive. Then, when you need to do something more specific, check the relevant documentation.

PHP's syntax is very similar to C, Perl, ASP or JSP. For people who know either of these languages, PHP is too easy. Inversely, if you know PHP, the language features can easily scale to other languages you want to learn.

To learn the core features, you just need 30 minutes. You already might know HTML very well, or you really know how to design good looking web sites, either using site builder tools or using plain HTML coding. Since PHP code can be added in a non-interfering way, after you design and implement your site, you can add PHP code to make it more dynamic.

Database Integration

PHP can be compiled with functions to interact with lot of databases. PHP with MySQL is a very popular combination. You can also write your wrap-around functions to indirectly call database functions. This way, you can easily change your code when you want to change your database. PHPLIB is a set of libraries written in PHP that provides most commonly required routines.

Extensibility

Like mentioned before, PHP has been evolving at a rapid pace. For a non-programmer it might be difficult to extend PHP to support additional functions, but for programmers it should not be very difficult.

Object Oriented Programming

PHP provides for Classes and Objects. Support for object oriented programming is sufficient enough for most programming tasks related to the web. PHP supports constructors, derived classes etc.

Rich Features

PHP is just a scripting wrap-around for many popular libraries, with a nice chocolate layer around it to make it easy to use for web. You can use PHP to connect to many databases including Oracle, MS-Access, MySQL. You can create graphics on the fly. You can write programs to download and display e-mail. You can even do network related functions. And best of all, you can decide what all capabilities your PHP installation should have. To quote Nissan's Xterra, your PHP can be made to have Everything you need, nothing you don't!.

Scalability

Traditionally, interactivity in web pages are achieved using CGI programs. CGI programs do not scale well, because, each run of a program occurs as a separate process. The solution is to compile the interpreters for languages used to write CGI programs into the webserver (mod_perl, JSP...). PHP also can be installed like this, though rarely people might want to use PHP in CGI version too. Embedded PHP installations scale well.

1.3 Competition : ASP, mod_perl, JSP

ASP is quite popular and I've written some applications in ASP since January 2000. Microsoft's arguments for ASP include availability of tools like Visual Interdev, language independence and easy learning curve. I have used VIM to code ASP, so I can't say much about the tools. Language independence is also not that much of an issue, just because in its default configuration it supports VBScript and JScript. You can also get extensions which makes it possible to write ASP in PerlScript making it a good choice for folks who are used to mod_perl and Apache. At least for a simple directory listing code, PHP3.0 on a P133 with 32MB RAM ran circles around ASP code on an NT4 machine with dual P500 with 600MB RAM! I tend to prefer PHP3. Also, VBScript's string functions are a pain to use (IMHO) - though it has REGEX capability now.

JSP has a very unique advantage that you need to know Java alone. From what I've seen, most people would prefer to work in one language and use that for as many purposes as possible. This, and the training costs involved will make Java an attractive option for companies. Additionally, there are already a number of tools out there for Java. Architecture-wise JSP+Servlets are comparable to VBScript+COM. For quick web-site building JSP may not be worth the trouble. For businesses, this would make more sense, especially since a number of Java based application servers are already in the market. From my personal experience, both Java and ASP need elite hardware, whereas PHP3 with Apache on Linux will perform adequately with your old P133 :-)

mod_perl is as powerful as Perl is. It is also quite fast. PHP4 with Zend engine will probably be as fast as mod_perl. However, Perl code can get unmaintainable quickly - this is just my opinion and goes well with Perl's idea of being a language for the lazy.


Next Previous Contents