Comment Re:PHP seems broken by design. (Score 1) 96
Perl, when used incorrectly, suffers from the same problem. The solution for complex scripts is to put the html code in templates just as you would in Perl. (See here for a fast templating package for Php.
Keep in mind that this is a design decision: allowing you to put code in your html makes sense when all you want is one or two lines of script.