I’m subscribed to the subreddit /r/programmerhumour - dedicated to humor and jokes relating to programmers and programming.
There are loads of great memes and jokes but my favourite has to be the hate that PHP gets on here. Its very amusing to see how offended some people get. Here’s one example
Why is PHP disliked?
I think PHP has a lot of dislike primarily because of the experience of working with it. Here is a somewhat famous blog post about PHP. This outlines a very detailed view of the poor design choices of the language, some of which have since been addressed in later PHP versions but still are things to be aware of.
A common ‘pro’ for PHP is that a lot of sites on the internet was built with it. My counter argument to this is, just because a lot of websites on the internet are built with PHP, doesn’t mean that the code behind them are good. There is a reason why PHP code often associated with ‘Legacy’ code, its too easy to write code that ‘works’ but also poor and unmaintainable. The argument that, majority of sites are built with PHP does not necessarily mean that that is a good thing.
Another common ‘pro’ is that Facebook is built with PHP. While this is true, Facebook also created a new programming language called Hack to alleviate the problems and headaches their developers were having when working with PHP.
It is mostly subjective when people say bad things about PHP (including me). Their experience working with are also anecdotes. But if you’re asking on a forum for someone’s opinion, you need to expect at least this much. Having experienced PHP professionally, I can kind of see why it gets a lot of hate. When comparing it to other languages, it is the one I would recommend the least.
Is it worth learning PHP anyway?
PHP over the years has gotten much better now. Its faster and frameworks associated with the language help with a lot of its problems. So using frameworks like Laravel can certainly help with the overall experience. If you can get past the awkward and clunkiness aspects of PHP, then by all means learn it.
However, the only strong reason I would consider PHP is because of job opportunities. If you have a lot of PHP opportunities in the area you live then it makes sense to learn it. However, if there are job opportunities in Python, C#, Java, Ruby or any other modern programming language, I personally would recommend those instead.
Why do programmers advise new programmers to ignore learning PHP?
Two years ago, I’ve responded to a question somebody asked on Quora: Why do programmers advise new programmers to ignore learning PHP?
To summarise my response:
its because the low learning curve and the flexibility of the language ironically allows new programmers to ignore best practices and learn bad habits really quickly if they’re not careful. The tutorials availble online are often out of date and are terrible to begin with. This can be a detriment to their growth as a developer.
I’ve left some examples of my own personal experiences with PHP and why I believed that PHP is not particularly a great programming language to start off with. Though in hindsight, my reasoning in the response is not necessarily an issue exclusive to PHP, and any dynamically typed language can experience this.
So maybe that excerpt isn’t a valid reason why PHP in particular is bad. A lot of the counter arguments are often related to the bad code being the result of developers instead of the language itself.
While this may be true, I still feel that when compared to other programming languages, PHP is the least enjoyable to work with in my experience. The syntax can be an eyesore, its very noticable when a third-party service supports multiple programming languages and you can toggle between them in their documentation, PHP is in my opinion the ugliest.
Other issues from setting up a development environment to inheriting legacy projects in PHP is also less than ideal. In my experience, it seems harder to get up and running as a beginner.
Summary
Is PHP bad? Not necessarily. Is PHP bad when compared to other modern programming languages? In my opinion, I would say yes.
It seems to me that there isn’t anything that PHP particularly excels in. All modern programming languages can do what PHP can.
There are many other more enjoyable programming languages. Languages such as Python, Ruby, JavaScript, C# all can basically do what PHP can and more. They all have frameworks, libraries, package managers and open source projects available. So when factoring all of PHP’s pros and cons, what can PHP do great which other languages can’t?
Would I recommend a beginner learn PHP? Only if there are no other opportunities which uses a different programming language. If the area you live in has opportunities in Python, Java, C# or Javascript/NodeJS/Typescript, then I would highly recommend those languages instead. Its only worth learning PHP if there are no other options in terms of job opportunities.
In any case, it is still good to have an open mind, anyone defending/attacking PHP should hopefully have had experience with it as well as other languages before casting judgement. Best to avoid focusing on what other people think and enjoy the memes.