I am new to programming and I've seen lots of posts making fun of PHP. Why does it gets so much hate? What language should I learn for web developing instead of it?
EDIT: Considering the fact that I already know JS.
PHP is incredibly popular. A lot of very useful things is written in PHP or what started as a dialect of PHP including WordPress, Facebook, and Wikipedia. PHP is ubiquitous and incredibly easy to get started with and so a lot of developers of very different skill sets have used PHP and written about it. As a result, there are a lot of tutorials, blog posts, and projects which demonstrate poor or unsafe practice.
Additionally, earlier versions of PHP made it difficult to write good code. PHP strives for a low barrier to entry and ease of use and this resulted in some terrible design decisions such as magic quotes. Aspects of the language from this time are often inconsistent from the perspective of someone using the language.
However, the language has seen steady improvement over the last several years. PHP 5 and PHP 7 have gone a long way towards transforming it in a modern language and resources such as PHP the Right Way demonstrate how to use the language effectively. Some old cruft still exists because it’s hard to change existing code but a lot of it is mitigated by an IDE that understands the language.