It's definitely unfortunate that PHP code in various websites across the web is designed horridly, it's also sad that we're unable to fix most things in PHP e.g. the needle-haystack problem, without destroying compatibility. HHVM has done a decent job at cleaning it up with Hacklang, but some of these legacy issues we're going to be dealing with for a long time.
PHP is evolving, many sites on the web are too. But legacy codebases are here to stay, I mean look at how many sites are still on classic ASP.
PHP was one of my first programming languages so I will defend it, the ecosystem is much cleaner than it was a few years ago, and it's still the easiest to deploy language IMO.