The History of Rewriting PHP
If you work on the web, you know that with software, things don’t always go right the first time. The web is this massive, global community tinkering with loosely connected technologies to piece together websites that, with any luck, work well together. These tools and technologies are always in flux and there have been plenty of stops, starts, and restarts. More often than not, a restart involves what’s referred to as a rewrite. This means that software is dismantled down to its core, and then put back together piece by piece in a way that (hopefully) vastly improves things for the people using it. On the web, things move so fast that rewrites are happening almost all the time.
PHP version 3 was one of those times.
In 1997, Andi Gutmans and Zeev Suraski decided that they were going to use PHP for their college coding project. Their university was in Tel Aviv and their assignment was to build an e-commerce shopping cart. Their teacher knew that PHP was still more or less an untested technology. She suggested that they try something different, something that was a bit more proven out, especially for something so advanced. But Gutmans and Suraski stubbornly refused and stuck with PHP.
Within the first few hours of getting started, they realized she had been right. They ran into one weird quirk in the code they were writing. Then another. After investigating a bit, they found that the problem wasn’t with their own code, it was embedded deep inside the PHP source code. There was basically no way to make it work, and therefore no way to finish the shopping cart. Thankfully, their teacher showed mercy and let them switch things up. Instead of a simple shopping cart, they would rewrite all of PHP from the ground up.
A lot of times, this is exactly how a rewrite get’s started. An active developer gets fed up enough with some software or tool or programming language and decides to give the whole thing another go. You’d just have to ask the creator of PHP. Because he did basically the same thing on more than one occasion.
The first major rewrite of PHP happened way back in 1995. Before Gutmans and Suraski even began working with the software, it would go through several more. The history of PHP is the history of changes and progression that stretches back to the early days of the web.
And if you trace it back far enough, you’d find that it at all started with CGI scripts.
To solve that particular issue, the folks at NCSA cooked up a Common Gateway Interface (CGI), first released in 1993. CGI allowed developers to use advanced programming languages, like C or Perl, to process and generate dynamic HTML. The technical specifics are far from important. What is important is that CGI gave programmers the ability to change the HTML of a webpage in more or less real time, so they could do things like keep sections of a webpage up to date, or process form submissions, or add comments to a blog post. All of the things that require the content of a webpage to update from its original version.
Rasmus Lerdorf was among CGI’s earliest adopters, and began tinkering with it not long after its release. He adapted some code he wrote to run using CGI on his personal website, mostly just to track the number of visitors coming to his site. Thinking there might be some others that would benefit from his work, and generally being an advocate of an open and free exchange on the web, Lerdorf packaged up some of the tools he had been working on and released his code to the public under the moniker “Personal Home Page Tools” in June of 1995. It went by PHP Tools for short.
His hope was that a few people might find the code useful. In truth, a small community of developers began to congregate around the tools, tweaking them for use in their own sites or projects. Some people even began contributing some code back to the project.
When Lerdorf realized he was on to something, PHP got its first major rewrite. Lerdorf got started on a rewrite almost immediately after PHP Tools’ initial release. In October of 1995, Lerdorf, with the help of a few other developers, got together a new, more unified version of the software. It went by a few names, “Personal Home Page Construction Kit” and for a brief time, just “FI (Forms Interpreter)”, but at its core it remained basically tools built on top of CGI.
This, however, would not last long. As more and more users began to use the software, Lerdorf once again realized that what he wrote wasn’t quite enough. People were actually using his loosely connected bundle of scripts as a replacement for a full-on programming language. For the geeks out there, that meant it wasn’t a combination of “C and PHP Tools” it was just “PHP Tools.” The software was stuck between two worlds. On the one hand, it was an extremely powerful CGI tool. But on the other, it was a sorely lacking programming language.
It was time for another PHP rewrite (that’s number 3 for those following along). In the spring of 1996, Lerdorf released an entirely new version of his tool, this time called PHP/FI. It was the first version of the tool that could actually stake a claim as a programming language, and went beyond just some dynamic content on a webpage. PHP/FI allowed developers to connect to a database, and process form data, and even extend the language with their own functions.
PHP/FI gained a bit of a following. It was pretty approachable as far as programming languages go, and it was specifically pieced together for the dynamic web. That had a kind of appeal for a growing number of developers that were focusing exclusively on the web. It’s also the version that caught the attention of Gutmans and Suraski.
Actually, Gutmans and Suraski, were using PHP/FI 2.0. As had become a bit of a tradition, shortly after the initial release of PHP/FI, Lerdorf once again got to work completely rewriting some of the underlying technologies of the tool. By the time the two students started tinkering with it in 1997, it had already been released as version 2.
Fast forward to the university project. Gutmann and Suraski were now tasked with once again approaching a rewrite of PHP. They got in contact with Lerdof and other developers that had been working on the project all along, and basically gathered some intel on where everything had come from and where it should go. They also set a few goals for themselves, which Suraski later related in an interview:
– Create a ‘real’ language, based on statements, expressions, and association rules, which was a big break from PHP/FI 2.
– Make it easy to extend by adding functionality to PHP/FI 2. This required changes to the parser and scanner, and generally speaking, it was quite a difficult task. We wanted to create a base that people would be able to easily contribute to and extend.
– Make it go much faster
– Do all of that while not flunking our university courses.
After a few months, they sent a completely rewritten parser for PHP over to Lerdorf. He was impressed enough to gather together a few more developers who had been actively working on the language to pull something new together. By the end, they actually managed to check all of Suraski’s boxes.
In June of 1998, PHP version 3 was officially released. It was faster, it took lessons from object oriented programming, cleaned up bugs, and added all sorts of new features. The language was renamed once again, briefly becoming “Professional Home Page Tools” before finally settling on just the recursive acronym, dropping all pretense to just become PHP.
If you work with PHP at all, version 3 is probably the earliest version you’d recognize. A lot of work that was done at the time managed to stick around, even to today. Before ti’s release, PHP/FI was running on around 60,000 websites. Within a year and a half, that number would jump to half a million.
Of course, this wouldn’t be the last rewrite of PHP. The language is still actively maintained, and received a pretty much major update a couple of years ago. Estimates put the number of websites that use PHP somewhere around 80% of all websites. It might have taken a while to get there, but eventually PHP was able to grab a foothold, and it hasn’t let go since.
Added to the Timeline
- "The Common Gateway Interface." University of Illinois. https://web.archive.org/web/20100127161358/http://hoohoo.ncsa.illinois.edu/cgi/
- "PHP: History of PHP – Manual." PHP Manual. http://php.net/manual/en/history.php.php
- Cabot Technology Solution. "The History of PHP." Hacker Noon. August 8, 2016. https://hackernoon.com/the-history-of-php-52a637c7b87f
- Ahmed Khan. "Candid Interview With Zeev Suraski, Cofounder of Zend PHP Framework." Cloudways Blog. December 12, 2015. https://www.cloudways.com/blog/zend-co-founder-zeev-suraski-interview/
- Matt Carr. "PHP – The History of the Programming Language Rasmus Lerdorf Started." PatraCompany. February 2, 2015. https://www.patracompany.com/blog/the-history-of-php
- Peter Judge. "PHP Forever – Andi Gutmans Of Zend." Silicon UK. June 6, 2013. https://www.silicon.co.uk/workspace/php-forever-andi-gutmans-of-zend-120288?inf_by=5ae247fb671db852518b4f00
- Paul Hudson. PHP In a Nutshell. 1st. O'Reilly, October 10, 2005.
- Shishir Gundavaram. "Some Working CGI Applications." O'Reilly. March 3, 1996. http://www.oreilly.com/openbook/cgi/ch01_03.html