Few talk about it but PHP drives a large part of the web
Feature On 8th June 1995 programmer Rasmus Lerdorf announced the birth of “Personal Home Page Tools (PHP Tools)”.
The PHP system evolved into one that now drives nearly 80 per cent of websites using server-side programming, according to figures from w3techs.
Well-known sites running PHP include every WordPress site (WordPress claims to run “35 per cent of the web”), Wikipedia and Facebook (with caveats – Facebook uses a number of languages including its own JIT-compiled version of PHP called HHVM). PHP is also beloved by hosting companies, many of whom provide their customers with PHPMyAdmin for administering MySQL databases.
[People] wanted to do everything in the stupid little templating language I had written, all their business logic
Lerdorf was born in Greenland and grew up in Denmark and Canada. He worked at Yahoo! (a big PHP user) and Etsy. He developed PHP for his own use. “In 1993 programming the web sucked,” he said in a 2017 talk.
It was CGI written in C and “you had to change the C code and recompile even for a slight change,” he said.
Perl was “slightly better”, Lerdorf opined, but “you still had to write Perl code to spit out HTML. I didn’t like that at all. I wanted a simple templating language that was built into the web server.”
The Danish-Canadian programmer’s original idea was that developers still wrote the bulk of their web application in C but “just use PHP as the templating language.” However nobody wanted to write C, said Lerdorf, and people “wanted to do everything in the stupid little templating language I had written, all their business logic.”
Lerdorf described a kind of battle with early web developers as PHP evolved, with the developers asking for more and more features while he tried to point them towards other languages for what they wanted to do.
“This is how we got PHP,” he said, “a templating language with business logic features pushed into it.”
The web’s workhorse
Such is the penetration of PHP, which Lerdorf said drives around 2 billion sites on 10 million physical machines, that improving efficiency in PHP 7 had a significant impact on global energy consumption. Converting the world from PHP 5.0 to PHP 7 would save 15B kW hours annually and 7.5B kg less carbon dioxide emissions he said – forgetting perhaps that any unused cycles would soon be taken up by machine learning and AI algorithms.
PHP is the workhorse of the web but not fashionable. The language is easy to use but its dynamic and forgiving nature makes it accessible to developers of every level of skill, so that there is plenty of spaghetti code out there, quick hacks that evolved into bigger projects. In particular, early PHP code was prone to SQL injection bugs as developers stuffed input from web forms directly into SQL statements, or other bugs and vulnerabilities thanks to a feature called register_globals that was on by default and which will “inject your scripts with all sorts of variables,” according to its own documentation.
There was originally no formal specification for PHP and it is still described as work in progress. It is not a compiled language and object orientation was bolted on rather than being designed in from the beginning as in Java or C# or Ruby. Obsolete versions of PHP are commonplace all over the internet on the basis that as long as it works, nobody touches it. It has become the language that everyone uses but nobody talks about.
“PHP is not very exciting and there is not much to it,” said Lerdorf in 2002.
Regularly coming fourth as the most popular language in the Redmonk rankings, PHP has rarely got a mention in the analysis.
That said, PHP has strong qualities that account for its popularity and longevity. Some of this is to do with Lerdorf himself, who has continued to steer PHP with wisdom and pragmatism, though it is a community project with thousands of contributors. It lacks corporate baggage and has always been free and open source. “The tools are in the public domain distributed under the GNU Public License. Yes, that means they are free!” said Lerdorf in the first announcement.
The documentation site is a successful blend of reference and user contributions which means you almost always find something useful there, which is unusual. Most important, PHP is reliable and lightweight, which means it performs well in real-world use even if it does not win in benchmarks.
25 years is a good run and it is not done yet. ®
Rojenx is a leading concept artist who work appears in games and publications
Check out his personal gallery here