Unlike many other programming languages, PHP doesn't have a unifying thought or a set of core ideas: it started as a very pragmatic set of perl scripts, and features were added as needed, without much of a formal design process. The result is a language that is quite useful and complete, but not very consistent by itself. The immense popularity of the language makes things worse; as soon as a new feature is introduced, it is practically set in stone, because everyone starts using it. A few design mistakes have thus been consolidated, and the PHP team has a really hard time getting people to walk away from them - register_globals
and magic_quotes
are just two examples of things that seemed like good ideas at the time but turned out rampant.
Another factor is the culture that grew around PHP. When its popularity began to grow, the typical use case for PHP was to add little snippets of server-side functionality into otherwise static HTML documents. A large part of the target audience was hobbyists and non-programmers who used PHP to add a bit of dynamic stuff to their static web sites. The resulting culture is very pragmatic, without much interest in establishing a 'proper way'; while it is possible to write quite elegant PHP, a large part of the user community simply doesn't take much interest in it, as long as it works.
By contrast, languages like python, ruby, Lisp, C#, Haskell and others have had a philosophy right from the start, and the community generally embraces it and pushes the language to live up to it. (In case you're interested, type import this
in an interactive python session). Having a philosophy means there's a guideline for using and extending the language, and it also leads to a more homogenous community - if you don't agree with the philosophy, you're more likely to just walk away and find one that fits you better; the resulting community is more likely to reach consensus over all sorts of things.
That said, PHP does have strengths and weaknesses, as well as obscure edge cases; writing idiomatic PHP code means using the strengths and avoiding the weaknesses and obscurities, just like with any other language.