Ok, so that may somewhat explain PHP's popularity for small to mid-sized projects, but it's also being used by most of the major websites like Facebook, Yahoo, Wordpress, Wikipedia, Apple, Flickr and many more. They clearly have the resources to use whatever technologies they want. Python, while being used by Google and Youtube, is still much less popular.
The problem with most of those projects is inertia. They started when PHP was the thing and most frameworks were poor quality or non-existent (in the case of yahoo, wikipedia and apple) or were started by people without the industry experience to know that better languages and frameworks (wordpress and facebook in your example).
For these companies, rewriting millions of lines of code isn't possible (in the case of Facebook, it was easier to write several million lines of code for a new PHP interpreter than it was to recode in a better, faster language).