I believe that programmers ability to write poor code is quite language agnostic.
I believe that programmers ability to write poor code is quite language agnostic.
The big problem with PHP is that it grew to popularity as it grew into a turing-complete templating language, and the major paradigm for it was more or less the idea that documents are programs. That actually encouraged mixture of logic and presentation concerns.
There are some other warts possibly worth railing at, but that's really the main place it gets its probably deserved reputation for having more spaghetti code, even though pros working in have long since moved on from that paradigm.
FWIW, this is also its strength: it's a very short distance with a gentle curve from authoring documents to authoring dynamic documents. I don't think anything else matches it.
Of course, the curve from there to a larger application, that can be a different story, depending on what kind of guidance one has (and most likely, without guidance, ontology will recapitulate philology, as they say).
PHP was suitable for new programmers because of how easy it is to deploy, learn. PHP3, the first version of PHP which was widespread, was released during the dot com bubble. When everyone and their mums was into Web. Everyone started writing tutorials, passing their shitty skill set. to new developers. Which produced more crap developers.