When I started learning PHP earlier this month, I excitedly shared my new goal with my editors, my colleagues, and my friends.
The response from anyone tech-savvy was always the same: “Why?”
PHP—which once stood for Personal Home Page, suggesting its roots in building simple yet customized websites—is a general-purpose programming language which lets you put interactive elements into a page.
When you run PHP on your website, you can turn pages from static, unchanging information pages to changeable, dynamic pages—like a blog homepage which instantly updates as you add new entries.
That’s why I became interested in learning PHP in the first place. WordPress, the popular blogging platform, uses it as the backbone of its theme engine, which is how you customize a WordPress website’s look, feel, and function. If you master PHP, you can tweak any WordPress blog’s most minute detail.
PHP—which now stands, recursively for PHP Hypertext Processor—is deeply embedded in some corners of the Web, which is why some people like me feel compelled to master it. But while I’m just getting started, it seems like other people have long been moving on.
The Long Decline Of PHP
PHP has been around since 1994. Back then, it was the very first scripting language that allowed programmers to build dynamic HTML pages easily and for free. Combined with its easy database integration, especially with the ultrapopular, open-source MySQL, it did everything webmasters needed with a low learning curve.
PHP experienced its biggest surge of popularity after Mark Zuckerberg, still in his Harvard dorm room, chose it to code Facebook in 2004. With a large popular site running it, PHP became an “it” language.
Yet even Zuckerberg & Co. have moved on to a custom language named Hack, which some developers describe as “all that PHP should have been.”
Today, PHP is past its prime. According to job search engine Indeed.com, PHP job listings peaked around 2011 and have since plummeted nationally.
What’s happening? With many alternatives to choose from for powering websites, like Python and Ruby, PHP is falling out of favor.
“PHP grew over time,” developer Tom Moor told me on Twitter. “There [are] a lot of quirks and oddities compared to other languages. For example, some methods have underscores, others don’t. Some take arguments in a different order for no reason at all. It’s basically guesswork.”
PHP is especially confusing because of its awkward start. While Python and Ruby began as functional languages from the start, PHP was originally designed to automate the building of HTML templates, and grew into a functional language later. As it added functionality, it picked up a lot of what Moor called its “quirks and oddities.”
A developer named Eevee wrote an oft-quoted rant on PHP, which someone even translated into Spanish. It’s received 2,000-plus comments since its 2012 publication. Here’s a sample:
Imagine you have uh, a toolbox… Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.
On top of that, developers criticize the backers of PHP for poor “stewardship”—a term in the open-source software world for a project’s quality of management and responsiveness to the community.
When asked in an interview how PHP (which is even slower than Java) could be sped up, creator Rasmus Lerdorf’s simple response was, “Well, you can’t.” (Lerdorf did not reply to my requests for comment on this or other criticisms of PHP raised.)
PHP Is Dead; Long Live PHP
And yet, for all the people who hate PHP, there are developers who love it just as fervently.
Thanks to its simple learning curve and high adoption in the past decade, PHP was the first language for a considerable number of programmers working today. For all its inelegant code, it’s still an effective beginner language. A friend of mine—who asked not to be named, lest he be drawn into the online PHP debate—suggested that it may be, for lack of a better word, sheer snobbishness that causes some to turn their noses up at it:
[Coders] don’t want newbies in their circle. They want veterans. PHP being open-source invites any mother, brother, sister, or dad to try it. You get a lot of people that are copy/pasters. The other languages are seen as the elitist languages. You aren’t cool if you don’t know .NET or Python or Ruby.
“Why do so many developers hate PHP?” asked leashlaw on Reddit. When he told a panel at a conference that he coded in PHP, his fellow panelists offered him their condolences.
“Elitism” was just one of the rationales other Reddit users offered leashlaw.
The bigger problem PHP has, they said, is all the old code still running on the Web, frustrating developers who have to deal with its idiosyncrasies. The fact that PHP is easy for beginners to learn means that there’s lots of websites out there filled with rookie mistakes.
“There’s a bit of a reputation with PHP that it’s slowly shaking off,” one redditor suggested.
One way to address PHP flaws would be to update the code to use the latest version of the language. Not that PHP made this easy—all three existing versions of PHP are incompatible. And old versions are incredibly persisent: It took roughly three years for PHP 5 to supplant PHP 4 as the dominant version installed on websites.
Things are better now. In PHP Is Not Dead, Drupal developer and blogger David Corbacho wrote that by 2013, 96% of sites running PHP are finally running PHP 5.
WordPress seems like it’s sticking to PHP for now, so I’m still working through Jesse Friedman’s book Web Designer’s Guide to WordPress.
It’s clear that PHP has a small but loyal fanbase, many of whom are beginning coders just looking for something easy to use and not worrying about how pretty their code looks.
So learning PHP will be a good exercise for me, and may help me with building websites. I just won’t expect my new PHP knowledge to be useful for very much else.
Photo by Manuel Baldassarri