While doing some research for my latest teaching job, I had reason to find out which are the most widely-used server-side languages used for web programming. The information provided by what seems to be the best source (although there are hardly many of them) gave some surprising results.
I knew that PHP was popular, but was surprised by the extent to which it outshines all other languages. Taking these figures at face value, it seems that knowing PHP is essential to a career in web programming. But that's hardly news.
Still, some things should temper any interpretation of this chart. The method used at W3Techs is not clearly made available, but they claim to automatically analyse the top-ranking 1 million websites for indicators of a technology (the HTML elements, URL structure etc). Without the method being made clear, it can't be determined whether there are any problems with false positives (judging that a language is used by a site when it isn't) or false negatives (failing to count a language that is used by a site). We simply have to assume the data is accurate.
Also, if we're asking which languages do we need for a career in web programming, another thing to consider is that PHP is the language behind a lot of frameworks which people deploy on servers so they can avoid programming: all those WordPress blogs, MediaWikis and Drupal sites. It could be that many analysed sites are blogs or wikis whose maintainers have never needed even to touch the code. Still, it's not uncommon that the need arises to delve into your framework's innards in order to customise it or fix a bug.
Despite these reservations about the stats, I'm still happy to agree that PHP is the mostly widely used language and it should be part of your toolbox if you wish to make a serious career in web programming. Here's two reasons to strengthen that notion:
You will probably maintain existing code
When you start a new programming job, you'll probably begin working on an already existing system. It's relatively rare to start a new system from scratch and choose whichever sexy technology you want; more likely, you'll be handed an existing body of code, thus the choice of language is out of your hands. And if you're using a framework, be aware that businesses have a knack for wanting a very specific bit of functionality from their software that the existing framework doesn't quite provide, meaning there's a real chance you'll have to get hands dirty in the code anyway.
Programming languages have staying power
Hardware and software are both part of "computing", but they often behave in very different ways. We're used to the hardware industry as one which constantly reinvents itself every couple of years: what rules the roost one year is old hat a few years later (read the excellent Innovator's Dilemma by Clayton M. Christensen for more on that). Programming languages are not like that. Writing software is a hard and expensive activity; once a program has been written and debugged, it becomes a dangerous and costly proposition to replace it with something new. Hence, programs tend to endure in ways that hardware never does. Languages like C, FORTRAN and COBOL have all been around since Elvis Presley was alive, but there are still billions upon billions of lines of code out there written in these languages. Why should PHP behave any differently? It's hard to make predictions, especially about the future, but experience of the software industry shows that whatever language is widely-used today will remain so for a long time. Don't bet on it losing popularity any time soon.