The honest and simplest answer is because people just hate it. Just like how some people hate Hilary Clinton, but cannot give any crucial reasons other than just hating her. This is the same with PHP. A large majority of people who hate PHP either hate it because of popularity or they just hate it because they don’t understand it. PHP is not really a beginner’s language if you ask me. Honestly, it’s a harder stretch because PHP really relies on logic. The logic I am talking about is how you construct your file, how you write each line, how you place things, how you understand each line, etc. About 99.9% of beginners fail to understand this. The reason is because they follow tutorials on the internet. Tutorial sites are the worst places to learn PHP from. Sure, all you do is copy and paste and then you got a working program. A monkey can do that. You really aren’t learning.
This is where people starts hating PHP. The noobies will copy and paste code from tutorial sites and won’t understand it at all. Then they start having these kinds of weird thoughts where they think they can just put things in random spots and have it “working”. But this again goes back to the logic part. For instance, most noobies will do something like this.
echo “Some kind of string line.”; header(“Location: new_file.php”);
And then wonder why it isn’t working. This is because of logic again. Headers always has to be set before any output. PHP is just an interpreter for HTML. This means PHP has to follow the HTTP protocol. So let’s try to explain this in simple terms. An analogy can be; the HTTP protocol is kind of like the Bill of Rights. It is the law of the land. In terms of the internet, the HTTP protocol is the law of the internet. Everything has to adhere to it. PHP is the interpreter. It is kind of like the police that governs or watches the citizens of the land. And you are the citizens of the land. You have to adhere to the HTTP protocol. This means when you write PHP code, you have to understand that header() calls are pretty much what injects code into the HTTP protocol. So to adhere to the HTTP protocol, you have to write your PHP code how it’s supposed to be written. Kind of like how you’re supposed to obey the speed limit or the laws of the state.
So going back to the code that breaks the HTTP protocol, you have write it like so.
header(“Location: new_file.php”); echo “Some kind of string line. But this line won’t appear because it’s redundant to have.”;
Again, this is where logic comes into play. The reason why it won’t “work” is because of “logic”.
Now, how does that relate to why PHP is so hated? It’s because of “logic”, most people hate PHP. When they see someone’s code, they hate how it looks. This is actually not PHP’s fault. This is the person’s logic. And thus this is where most people hate PHP. Because they see noobies write in PHP and then despise it.
Other than that, it’s also because they are a huge fan of other languages and all they want to do is talk trash about PHP for no reason. This is when most of the trash talkers get really irrelevant fast. They cannot supply any supporting details and they cannot back up their own argument. They will provide such links like a 2012 Eevee post that’s also based on opinion and try to pass it off as “facts”. These types of people are generally the ones that start talking smack, but can’t finish what they start. Like they say
“Don’t bite off more than you can chew.”