A short history
PHP (which originally stood for Personal Home Page) was first written by Rasmus Lerdorf as a simple set of Perl scripts to track users of his Web pages. He soon had enquiries from other people and rewrote it as a scripting engine. He also added support for forms, thus forming PHP/FI. As its popularity grew, a core group of developers created an API for it and turned it into PHP3. By now PHP was being used in situations which were never envisaged, and so a complete rewrite of the script parser was undertaken (the Zend engine), creating PHP4, which was much faster than PHP3. PHP now stood for PHP Hypertext Processor, and was ready for the big time...What to look for in a scripting engine.
The Four S's: Speed, Stability, Security and Simplicity.
- Speed -- not only the speed of execution, which is important, but also that it not slow down the rest of the machine. So it should not demand a lot of system resources. PHP integrates well with other software, especially under UNIX's, has a small footprint and when run as an Apache module is already loaded for use. Plus, PHP is a thin wrapper around many operating system calls, so can be very fast.
- Stability -- its no good being fast if the system crashes every few thousand pages. No application is bug free, but having a community of PHP developers and users makes it much harder for bugs to survive for long. Under the hood, PHP uses its own resource management system, and has a sophisticated method for handling variables, making it intrinsically a robust system.
- Security -- the system should be protected from malicious attacks from users, both as programmers and as surfers. PHP provides many levels of security which can be set in the .ini file to the desired level.
Oh, and Connectability (which doesn't start with an 'S'). Because of PHP's modular system of extensions it will interface with many diverse libraries, and adding further extensions is very simple. This allows PHP to make use of specialised working libraries from many different areas, such as encryption, graphics, XML and so on.Further advantages of PHP.
- PHP will run on (almost) any platform. Using the same code base, PHP can be compiled and built on about 25 platforms, including most UNIXs, Windows(95/98/NT/2000) and Macs. As this uses the same code base, all scripts will run identically, whatever the platform.
- PHP is extendible. PHP consists of the core parsing engine (written by Zend), a set of core code modules and then a set of code extensions. This allows programmers two ways of extending PHP to do some special processing, either by writing an extension module and compiling it into the executable, or by creating an executable that can be loaded using PHP's dynamic loading mechanism.
- Lots of HTTP server interfaces. PHP currently will load into Apache, IIS, AOLServer, Roxen and THTTPD. Alternatively, it can be run as a CGI module.
- Lots of database interfaces. PHP currently will work with MySQL, MS SQL, Oracle, Informix, PostgreSQL and many others. These are binary level interfaces, and ODBC is also provided for those situations where the database is not supported.
- And lots of other modules... when a PHP user wants to interface to particular library, then it is easy to write an interface for it, and many have done so, and contributed to the main PHP source repository. So you can find modules for graphics routines, PDF files, Flash movies, Cybercash, calendars, XML, IMAP, POP and a host of others. If the library you need is not supported, you can either write one yourself, or employ your favourite programmer to do it.
- PEAR. The PHP Extension and Add-on Repository. Similar to the CPAN network for Perl, although still in its infancy, the idea of PEAR is to provide a set of PHP scripts that would be installed by default with the PHP installation
- Fast. PHP is normally used an Apache module and this makes it very fast. It is entirely written in C and is quite small, so loads and executes quickly with small memory footprint.
- PHP is Open Source. Almost a religious matter to some people! In purely practical terms, it means that you are not dependent on a manufacturer to fix things that don't work, nor are you forced to pay for upgrades every year to get a working version. Those of us who have waited for Allaire to get something fixed will appreciate this.
Error handling is not as sophisticated as Cold Fusion or ASP.
There is no IDE or debugger. An IDE is probably not important for most people and a debugger is promised from Zend Tech. in the very near future. Most people continue using the same environment they use for HTML development.When should you use PHP, and when should you use another scripting language?
If you are running on a UNIX or Linux platform, you have the choice between Perl and PHP, both excellent for scripting. Where PHP has the edge is in being much simpler for people new to writing scripts, making it more productive in the earlier stages. Perl also relies on having the correct modules downloaded from CPAN for some of the more off-beat functionality, whereas they come as part of the PHP distribution. Of course, there's no reason not have both Perl and PHP!
On a Windows platform, there is competition from ASP and Cold Fusion. Here the choice can be as much political as technical, and ASP with IIS is probably a safer bet than PHP with IIS. But on a purely technical basis, PHP is as stable on WindowsNT as either of the other two, at least as fast and less resource intensive. However, ASP offers far better integration into the underlying operating system and databases, especially if you want to make use of COM.Conclusion
Like so many things in the programmers tool kit, PHP has developed almost accidentally. What started as one person's experiment with scripting, managed to fulfil a need for many other programmers, a need for a small, fast and simple scripting language that could work seamlessly with many other components. In the last three years PHP has grown to become a major player in the server side scripting market.
Recently, another acronym was coined, LAMP, standing for Linux, Apache, MySQL, PHP - now considered an important package in the Internet world, a set of programs that work together to produce dynamic, data-driven Web sites.
A list of high profile sites can be found at www.php.net/sites.php, among them are sites that cover the whole range of the Net, from computer magazines to government, finance to games.Resources
www.php.net - PHP.net, the central PHP site.
www.zend.com - Zend, home of the PHP parsing engine. Plus many interesting tutorials and articles.
www.phpbuilder.com - PHPBuilder, a PHP resource, with articles and tutorials.
http://px.sklar.com/ - the PHP code exchange containing snippets of PHP code.