Why PHP?
We expect our readers to have a more than firm handle on what PHP is, but for completeness-sake: PHP (a recursive acronym of PHP: Hypertext Preprocessor) is an open source, server-side web-scripting language for creating dynamic web pages. Outside of it being browser independent, it offers a simple and universal cross-platform solution for e-commerce, and complex web and database-driven applications.
PHP has:
- A low, smooth learning curve.
- Broad functionality for databases, strings, network connectivity, file system support, Java, COM, XML, CORBA, WDDX, and Macromedia Flash.
- Platform compatibility with UNIX (all variants), Win32 (NT/95/98/2000), QNX, MacOS (WebTen), OSX, OS/2, and BeOS.
- Server compatibility for Apache module (UNIX, Win32), CGI/FastCGI, thttpd, fhttpd, phttpd, ISAPI (IIS, Zeus), NSAPI (Netscape iPlanet), Java servlet engines, AOLServer, and Roxen/Caudium module.
- A rapid development cycle.
- New versions with bug fixes, additional functionality, and other improvements are released every few months.
- A vibrant and supportive community. Code examples and free code abound. The PHP group has done an excellent job of providing new users with resources and support.
- Easy extensibility. We can easily roll out our own extensions to the language.
- A simple syntax that resembles C. It's easy for experienced C, C++, Perl, and shell coders to pick up PHP.
If you're new to PHP, here's a quick run down on where it's been, where it is now, and where it's going. We will tersely summarize the history of PHP here, but we urge readers interested in the historical aspects of PHP development to review the introductory PHP presentations at conf.php.net or read the Brief History section in the PHP/FI 2 manual at php.net/docs.php.
Rasmus Lerdorf conceived the idea of PHP in the fall of 1994. Version 1 of the language was implemented in early 1995 and was embraced by a handful of users, following which Version 2 was released later the same year. Versions 3 and 4 followed in 1997 and 2000 respectively.
As of the time of writing, PHP usage is growing at a rate of 15% each month, and is in use on at least seven million domains (Source: Netcraft Survey), which is about 20% of all the domains registered so far. This is a significant chunk of the market, given that these figures do not account for the multitude of installations that run on intranets and private development servers.
PHP runs on 7 major platforms (stable), 10 server interfaces (stable), supports 40 stable extensions (and about as many experimental ones), and offers support to over 20 databases. These figures are testimony to the fact that PHP has grown to its current popularity based on its power and ease of use.
With PHP3, the parsing and compiling of PHP code happened simultaneously, thus reducing the basic start-up time for execution to begin. This was the main reason behind the high performance of simple scripts. Sadly, when it was burdened with the onus of handling complex scripts, there arose a redundancy in terms of parsing parts of the code over and over again, as with loops and repetitive function calls. The core engine was at fault, and so it became obvious that this was the first area to attack in the race for performance, thus instantiating the development of PHP4.
The PHP4 scripting engine is a second revision of the PHP3 scripting engine, and provides more obvious infrastructure and services to the function modules, and implements the language syntax. This revised version is largely based on the same parsing rules as the PHP3 engine, thus providing good backward compatibility and migration path from PHP3 to PHP4. But the downside is the limited scope of language-level improvements, to the PHP3 mindset.
For those who have migrated from other scripting languages, we have detailed a section on why you just made the right choice.
PHP vs. ASP
ASP (Active Server Pages) is Microsoft's proprietary scripting "language". Loosely speaking, ASP isn't a language, but a scripting extension of Visual Basic. For this reason, ASP is relatively easy to pick up for anyone who is familiar with Visual Basic. Disadvantages? For one, ASP is generally slower than PHP. ASP is a fundamental user of COM-based architecture.
So, when an ASP programmer accesses the database and writes to the client, they're calling upon the COM strictures of another NT service or an OS layer to assist. This COM overhead can add up and results in average performance for anything more than medium-traffic simple page delivery.
Also, ASP isn't exactly ready to port and integrate with GNU tools and open source environments or servers. Since it's a proprietary system of Microsoft, it is mostly used on their Internet Information Server (IIS), which limits common adoption of ASP to Windows 32 bit systems – where it comes as a free piece of code to most server customers.
There are versions for UNIX (see ChilliSoft ASP) and several ASP interpreters for other systems and web servers, but the cost, together with performance, then becomes a concern. A solution to this problem might be to use the asp2php program, which will convert ASP to PHP.
ASP.NET is a very different animal though. The future may bring some highly significant performance and scaling improvements in ASP. This is achieved by a further leverage of the .NET/COM architecture and management environment. However, the real advantages may only be available to those that spend heavily on various associated servers.
PHP vs. Cold Fusion
PHP runs on virtually every platform; Cold Fusion is only available on Win32, Solaris, Linux, and HP/UX. PHP initially requires more programming knowledge in contrast with Cold Fusion, which has a refined IDE and simpler language constructs. PHP is less resource intensive.
PHP vs. Perl
Since PHP was designed specifically for the Web, it has the upper hand on Perl in this area, since Perl was designed for myriad applications (and consequently looks the part). The format and syntax of Perl can make a Perl script hard to read and modify later when updates are needed.
Though Perl has been around for quite some time (it was developed in the late 1980s), and is widely supported, it has grown into a complex structure of additions and extensions and is simply just too much. PHP has a less confusing format without losing its flexible nature. PHP is easier to integrate into existing HTML and offers similar functionality to Perl, but with so much more grace.
PHP vs. Java
PHP is simpler to use than Java and makes it easier to architect web applications while also gaining similar advantages of flexibility and scalability. Using PHP doesn't require 5 years of software engineering experience to create simple, dynamic pages and can be used by savvy, but inexperienced, computer programmers.
Java is often expensive too, as most companies end up having a stand alone box to run Java Enterprise and use Oracle and other expensive software. Having said all that, PHP still has to grow and in that it's not as portable or doesn't have some of the nice features like object pooling or database mapping as in Java. These issues are being addressed in the Zend 2.0 engine design considerations.
The sheer number of PHP resources is overwhelming. Here are some of the more important parts of PHP that are often overlooked:
- PHP's Official Web Site - Everyone knows and visits the PHP web site. However, there is a lot of information on the site. It is often worth the time digging around on php.net before going anywhere else. Some of the information on the site is a bit hard to find, but is well worth the effort.
- PHP Conference Presentation Archive - A good number of the presentations given by leading PHP community members is archived on this site.
- PHP4WIN - PHP4Win is an excellent resource center for developers who run PHP on Windows.
- The PHP Mailing List Archives - The PHP mailing list archives contain a wealth of information. Many of the mailing lists have been continuously archived for several years. Stored in the archives are the answers to many questions.
- Snapshots of Recent Development Builds of PHP - PHP has a very rapid development cycle. Features are added and bugs are fixed on a daily basis. If you want to get the latest version of PHP to take advantage of a new feature or a bug fix, you can visit this site to download a version of PHP that is a few hours or days old.
- Web-based Browsers for the PHP Source - There are three different online tools that allow you to browse through the CVS repository. CVS is a version control software tool that the developers of PHP use to manage the many hundreds of files that make up the PHP project. For more information on CVS, visit www.cvshome.org.