I began using PHP in 1998 and used it heavily until 2004 when I discovered ASP.NET (C#).
I still maintain a few PHP-based web sites, but I will admit the bulk of my recent web development has been with ASP.NET (C#). If you do the math I have been a PHP programmer longer than I've been an ASP.NET programmer.
What the hell is a "NAMESPACE"?
Coming from the PHP-world, ASP.NET was a challenge. ASP.NET is comprised of strongly-typed variables, true OOP, namespaces, event-driven execution, web controls, compilation, etc. I spent weeks trying to accomplish simple tasks and failing. Many of these concepts were foreign to me. After reading many books & web pages, I eventually had an epiphany and all has been well since.
I will be very blunt, ASP.NET (C#) made me a much better programmer. PHP, by comparison, was a kids' toy. Each time I inherit a new PHP web site, I'm reminded of this. There is no formality or structure to any of it. Programmers will happily toggle into & out of HTML, PHP, Javascript and SQL. If they are really fancy they might even `escape` to the shell and toss in a few UNIX commands. All of this is done while magically creating and retyping variables without a second thought.
I have come to understand this is...retarded. Although it makes it easy for "newbies" to get things done, it does not lend itself to managing large-scale enterprise web applications.
This lack of structure makes the product an unmaintainable mess. Doing something as simple as adding a new bit of HTML becomes a "process". After spending 4 years with ASP.NET, "mixing my layers" now makes me feel dirty and compromised. For most PHP programmers I've encountered, they do this without a second thought; gleefully reveling in their chaotic mess like a small child experimenting with a bucket of paint.
Hey wait a minute; the problems you describe are caused by bad programmers, NOT PHP!
This is true...mostly. There are some amazing large-scale web applications that are using PHP. It's obviously possible to create good PHP code. However, the PHP language itself and the PHP culture does not actively require (or even encourage) "good form". This means "maintainable PHP" requires a high-degree of discipline from the programmer.
I did a Google search for "PHP best practices"; this was the first page found. The leading paragraph states:
One of PHP's greatest strengths can also be a great weakness in the wrong hands. I'm talking about its forgiving nature. One of the reasons why PHP has become so wildly popular is because it lets very inexperienced web developers build powerful applications without much planning, consistency, or documentation. Unfortunately, that means an awful lot of PHP code out there is sloppy, hard to read and impossible to maintain.
This is exactly my impression as well. The article goes on to describe various "good form" techniques for using PHP. Unfortunately, the article only focuses on making code more "readable". For example, it addresses why you should indent blocks of code. It does not really address how to structure large-scale PHP applications. To find information about creating an organized/layered PHP web application, I had to do a bit more searching. I found the following web page:
http://www.odi.ch/prog/design/php/guide.php
This is as close as I came to someone demonstrating "good form" with PHP. Although, I note the "require_once" function is needed to pull this off. Wow! Let me quickly say; PHP should be downright embarrassed that in the year 2008 they STILL don't have namespaces.
Adrian Holovaty of the Django/Python fame has a slide in his presentation (check the 11:00 minute mark) that is a screen-shot of the "reserved" PHP words for the letter "A". It always gets a good laugh from the crowd and effectively demonstrates the problem with having no namespaces. The absence of these "standard" language features is why the PHP language does not actively encourage "good form". Is it possible? Certainly, in the hands of a talented & disciplined programmer anything is possible. However, the programmer pulls this off in spite of PHP, not because of PHP.
In the end, I'm for whatever works. There may be a variety of reasons why PHP makes sense. Ultimately, it is important to understand the strengths and weaknesses associated with technology choices so you can craft the best possible solution.
Additional comments can be found here.