Why I Love PHP

While I was just reading an article titled PHP: a fractal of bad design I felt the need to defend PHP. Over the years PHP has gotten a bad reputation and is regularly railed on. Yet, I’ve recently grown to like using PHP again. If you’re curious why someone would like PHP (or insight into my possibly twisted world) here you go.


I’m an engineer. I like to build things that work and take into account the ilities. If you want to discuss the nuances of language design talk to a language designer. If you want to talk about designing the perfect language you might consider talking to a philosopher. Or, if you look at a lot of well engineered failures consider looking at bridges. When they fail it’s a big deal.

Some Context Surrounding PHP

It’s important to understand some elements of PHP and how it’s used. Making judgments about something without understand the context surrounding it can be short sighted and cause problems. Understanding context and history can help us understand why decisions were made and even evaluate if something was a healthy decision or not.

Target Audience

Not all programming languages are created alike. PHP is built for the web. On php.net it puts it this way:

What is PHP? PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Many languages are general purpose languages or have their own targets. For example, python.org states:

Python is a programming language that lets you work more quickly and integrate your systems more effectively.

PHP is targeted at the web while Python isn’t. That means decisions are based on different criteria. So, when it comes to PHP a mass majority of the discussion centers around the web. For other languages this may not be the case. For example, I’m writing this post in an editor written in Python. Can you imagine a desktop GUI application in PHP?!?!

Long History Of Popularity and Usage

PHP is used by 77.5% of sites where the language can be detected. Let that sink in for a moment. PHP is popular and has been for a long time. Ten years ago PHP was really popular. While we often talk about the amount of time a language has been around there is a difference between a popular language and one that’s a lot less popular.

To put popularity into context we need to look at the web. The web is a lot more than Facebook, Google, the other huge sites, and the hot new startups. The long tail of the Internet is really long. That includes the blogs of people living with cancer, the stores in suburban villages, the websites sharing pictures of cats with the world, and so much more. Most of these sites don’t have engineers or IT on staff. When you make language decisions and have this audience you are attempting to be benevolent with it’s not as simple as making decisions on a whim or even those to clean up language design.

Now that I think about it, handling this long tail well is one of the reasons I love PHP.

Ever Language Has It’s Ugly Spots

I’ve written terrible code in over a dozen languages. I’ve seen the ugly spots in many languages. For example, Python doesn’t have interfaces. Some people may like it and others don’t. To some, this is an ugly spot. While it’s popular to rail on PHP for it’s ugly spots, every programming language has ugly spots for some developers.

Why I Love PHP

Let me count the ways…

  1. The language can be hosted almost anywhere. I’ve worked on applications for the web intended to be installed and used by others. To help the long tail. The wide availability of hosting is something amazing. While this isn’t great for people who are writing their own application in an environment they intimately control, for some of the use cases I work in this is great.
  2. PHP has some nice underutilized features. For example, PHP Stream Wrappers. If you want to store files in a remote storage (e.g., S3) you might use a library. In Ruby you might use Fog or Java you might use jclouds. To use these you have to write you application around them. With PHP you can have your code use the same underlying file handling code for a file system and implement a stream wrapper to make the remote location work. No rewriting your codebase to work with remote apis. You just work with files like you always have. This was a feature we took advantage of with some recent HP Cloud Object Storage work. This is just one example among many.
  3. Since PHP doesn’t force us into a coding style there are now some nice frameworks being developed and well written articles being shared. In PHP you can write maintainable, well written, code that takes into account the illities.
  4. PHP is well documented and contributing to the documentation is something anyone can get involved in. I love documentation so this hits close to home.
  5. Developing with PHP is becoming a wide open field again. For some time PHP felt out dated and crufty. There was a lot of ugly code and ugly processes. When I looked at PHP I thought of applications like Wordpress and Pear. PHP has been reinvigorated with projects like Symfony, Composer, and Assetic. There is a movement of good quality code and it’s fun to watch or contribute to.

I could go on and on but, I have to go write some PHP code. If you have reasons to love PHP or maybe just like it please share. I’d love to read what others think as well.