The original release of PHP was created by Rasmus Lerdorf back in the middle of the 90s as a way of making common web tasks easier and less repetitive. Back then, the main goal was to have the minimum amount of logic as possible in order to achieve results, and this led to PHP being HTML-centric - that is, PHP code was embedded inside HTML.
The first popular version of PHP was called PHP/FI 2.0, for Personal Home Page / Form Interpreter, and, despite its parsing inconsistencies, managed to attract a fair few converts, including myself. The main issue with this version was that the PHP/FI parser was largely hand-written, and so users often encountered scripting errors that were technically not errors - they were just the PHP/FI parser screwing up. Furthermore, the parser was absolutely tied to the Apache web server, and was hardly renowned for its speed.
Author's Note: The parser is what takes your script and converts it to something the computer can understand. It comes from the word "parse", which means to break text up into components and analyse them.
Some of these issues were resolved in version 3, when Zeev Suraski and Andi Gutmans re-wrote PHP from the ground up using standard "compiler compiler" tools like Flex and Bison. This made the parser itself all but bulletproof, which in turn gave sanity back to many PHP users.
PHP 3 also finally made the language extensible - something that was seriously lacking from prior versions. Particularly keen developers were able to write their own modules for the language, adding functionality at the core level. The parser itself, though, was still tied to Apache, and, although speed was improved a great deal from PHP/FI, it still was not anything to shout about.
The only downside to upgrading to PHP 3 was that the language was a lot stricter - some code that worked on PHP/FI would no longer work after upgrading. The language was still young, though, so not many were affected.
The all-round improvement brought about by the PHP/FI to PHP 3 upgrade brought in many new users eager to jump from the Perl ship to a system that was easier to use. At the time, there was no doubt at all that Perl was faster to execute, except perhaps among PHP zealots, however PHP still kept its lead in speed of development, and that was the key selling point.
With PHP 3, the language had gained limited object-oriented support, and this only added extra fuel to the fire of PHP's growth. By the time PHP 3 was replaced in the middle of 2000, it was installed on over 2,500,000 web-site domains, as compared to 250,000 just 18 months before.
In the middle of 2000, PHP 4 was released to the world, containing major differences to PHP 3 in all aspects. Extensive work had been done to ensure that backwards compatibility with older PHP scripts would remain - upgrading from PHP 3 to PHP 4 was much smoother than the PHP/FI to PHP 3 upgrade.
Perhaps the most important change made for PHP 4 was the switch to what is called the Zend Engine. The Zend Engine, created by Zend, a company founded by Zeev Suraski and Andi Gutmans (the name Zend is a contraction of ZEev and aNDi) to promote PHP in the corporate environment, allowed much more flexibility than had ever been seen before in PHP. The engine took over the core of PHP and introduced reference counting, whereby all resources used in scripts (database connections, files, etc) are tracked automatically by the engine, and freed when no longer used to minimise memory usage and ensure there were no memory leaks.
Also introduced with PHP 4 was complete web server abstraction, meaning that PHP now runs on Apache 2, Microsoft's IIS, Zeus and more. This opened use of the language up to the 50% of the world who don't use Apache for their web server.
Performance took a gigantic leap forward due to two main factors. Firstly, the execution paradigm was changed from prior versions. PHP 3 and before used an "execute while interpreting" paradigm which meant that PHP read a line of source code, interpreted it, executed it, read another, interpreted it, executed it, read another, etc. This meant that code was often re-read and re-interpreted twice or more, entirely unnecessarily.
PHP 4, with its new "compile first, execute later" paradigm read your entire script in and compiled it to byte code before execution, which produced a large speed increase - the average speed increase was about 100%, with some benchmarks showing up to a fifty-fold increase in speed when PHP 4 was pushed to its limits.
Author's Note: "Byte code" is the name for the internal representation of your script that PHP can understand easily - it is usually a lot longer than your script as a result of each PHP statement being broken down into many simple byte code statements.
Furthermore, because PHP 4 compiled the entire script before executing it, it became possible to optimise and cache the compiled code before execution. We will be looking at how this works later on in the book.
Secondly, PHP 4 introduced multi-threading, which essentially allows particularly lengthy, but non-critical functions to be run independently from the main script process, further streamlining execution.
After years of loyal service, support for PHP 4 was discontinued at the end of 2007, and should not be used for any new coding.