PHP is so popular for a few reasons:
It sucks but it’s a modern-day kind of suck. Not a 10 years ago kind of suck which is altogether a different kettle of fish.
The WWW is still young enough that you can get a lot of eyeballs with applications that are of the “low hanging fruit” variety. Put another way, the apps aren’t doing terribly complicated things but what little they do can be popular because we haven’t gotten to the more complex things yet.
A lot of the complexity lives on the server (I’m thinking RDBMSs, back-end processing, etc…).
I expect most of those popular websites to move to a more structured framework by the time AJAX 2.0 is passe. They’ll crumble under their own weight if they don’t.
PERL apps followed a similar trajectory. PERL was so easy to use that you could get a working product out the door in much less time. By the time you’re on your 6th version, feature creep + a too-freewheeling language have prompted a rewrite in either java or C++…