Most PHP code is terrible. That's not really PHPs fault - it's capable of producing very nice programs with beautiful behavior.
As a language, it suffers a bit from being older and it was internally very inconsistent for a long time. For a long while, it's package management and practices were way behind the curve. Many people who program in PHP learned it as a first language, hacked together programs in it, and probably used hack together libraries and tooling.
PHP can be used with grace, but most people don't have that experience with it.