This is a repost of my answer to the Quora question: Do a large majority of people hate PHP solely because other people do so?
There are a lot of reasons people “hate” PHP, or at least look down on it. Some of them are founded, some are not, and some of them are circumstantial.
1.) “Inconsistent haystack / needle”
You hear a lot of people banging on about inconsistent haystack needle, but this can be read with a single rule:
array: needle, haystack
string: haystack, needle
It’s as simple as that, but people often forget and assume its more complicated.
2.) PHP is a HTML file, with logic
PHP assumes the file will be HTML first, which can lead to some stupid output problems where whitespace sneaks in before or after those tags. There are some plans to change that, but it can lead to trouble and reminds everyone that PHP has a history of “templating first, programming later”.
3.) No standards
There are a million frameworks with a million standards, people fight over snake_case v camelCase and have no clear plans as to what is correct. That means people coming from Ruby to PHP (say they have to build a PHP library for a REST API they just built) they have no idea what to do. I’ve seen this problem a lot, but the PHP-FIG (Previously known as the PHP Standards Group) is working on that.
4.) Lack of Quality Packages
NPM, Bundler/Gems, PIP, CPAN etc all provide quality code packages for developers to plug into their code, meaning they can write less and do more. PHP does not have a consistent package system other than PEAR, which is an aging beast which most people ignore due to the low quality or old age of the packages.
PSR-0 (part of the PHP-FIG) is a standard that has been generated to help code packages work together, and Composer is a project that has been built to make NPM-style dependency handling for PHP. In time we’ll see the quality increase, meaning much less bad code is going to be rebuilt time and time again by every developer - and much more time can be saved instead of developers working on fragmented “framework specific” solutions.
I know a bunch of incredibly smart Ruby developers who used to use PHP back in the PHP 4 days, who seem to think nothing has changed. PHP 4 to 5 was a massive jump and PHP 5.2 to PHP 5.3 was another HUGE leap forward (after-all, PHP 5.3 was meant to be PHP 6 but they back-ported every feature other than Unicode which was not going to work).
The fact that they go around telling all their Ruby friends that PHP has no “method_missing” (we do, it’s called __call()) and complain about other things that no longer exist, or have been improved, or added, means that a lot of people who laugh about PHP are laughing about a 7 year old version of PHP. Somebody said PHP was terrible for not having a built in server like Ruby… well it does.
6.) You were doing it wrong
“You can mix MySQL, HTML and PHP in the same files. PHP is disgusting!”
I’ve said the same about ColdFusion and had it politely explained to me that I was just doing it wrong. This is a good point. Just because a language is flexible enough to let you do whatever you want does not make it bad.
The structure comes from a framework. I don’t know many people using Ruby who aren’t using Sinatra or Rails, and I don’t know many Node guys who don’t use Express, CanJS, etc.
Not using PHP is cool. Who wants to use the same language you used when you first started writing code as a kid? Who wants to use something that has loads of terrible script kiddies using it? It must not be a challenge, it’s not smart enough for a smart programmer like you.
You need something that will challenge you and anyone using PHP is just not smart enough to learn something else…
I hate that point of view so much. In the lift today on the way in, my colleague overheard a conversation from two total strangers: “You can’t trust these PHP shops, why don’t they learn a real language?“. This covers a lot of the views of people around, and if it’s not elitist then it is at least short sighted.
So, why do people still use PHP?
If nothing else; Momentum
The latest stats from the W3Techs show that almost 78% of the top million sites are built with PHP. Now, while you can sniff at the quality of the language itself you can’t sniff at that.
I am proficient in PHP, Ruby, Python and have dabbled with NodeJS. Why am I using PHP? Because it has the biggest market.
Lots of developers want to chase “the perfect language”, “the perfect IDE”, “the perfect hosting platform”. The answer is that there is no perfect tool, just options. Nobody should be “hating” any of them.