I would like to learn PHP for web development but have been drawn back because of comments like the following*:PHP is good but generates spaghetti codePHP is nice but Python is marriage materialPHP lacks stuff that you get in other languages like C# or JavaBut for PHP5 I have seen some promising comments. So, my question is: How does PHP5 fare with earlier versions of the language and is it good enough now to learn for web development. * Comments are just for reference not to incite a flame war. No comparison of PHP with other languages is asked for here. Please comment just on PHP5 and how it compares with earlier versions.
How does PHP5 fare with earlier versions of the language
php
When discussing languages, these two Stroustrup quotes always pop in mind:Anybody who comes to you and says he has a perfect language is either naive or a salesman.andThere are only two kinds of languages: the ones people complain about and the ones nobody uses.Now to the question at hand. Most of the hate is mostly directed at PHP4. PHP5 was first released in July 2004 (beta a year earlier) and the last version of PHP4 is 4.4.9 released on August 2008. There is no valid reason to use PHP4 anymore, unless of course you maintain some legacy app. PHP4 is no longer supported by the PHP group, and we all hope it fades away soon.The gap between the two versions is bigger than it usually is between two major releases, as the engine behind the interpreter was rewritten from scratch, and included a new object model. The release of PHP5 roughly coincided with the release of MySQL5, a major overhaul of MySQL. PHP is usually coupled with MySQL and the fifth version of both addressed several issues and brought them up to speed with the competition. MySQL is also subject to FUD comments, but, well, it's the database behind Google's AdWords.PHP 5.3 was a major release in everything but name. A lot of features that where intended for PHP6 found their way in 5.3 and for every 5.2 developer out there I'd strongly advise to migrate to 5.3+ sooner than later. The current release, 5.4, includes some awesome features (amongst others):Namespaces,Late static binding,Jump labels (limited goto),Native closures,Nested exceptions,TraitsNow for your specific comments:PHP is good but generates spaghetti codeThat's absolutely not true. No language generates any kind of code, it's always up to the developer to screw up, spaghetti code is possible in every language out there. What is true though is that PHP has a very low entry barrier compared to other popular languages, hence it's a lot easier for inexperienced developers to write bad (but working) code. But that's a side effect of every easy to learn language. Furthermore PHP does not enforce any particular style or paradigm, and it's always up to you to decide what to do. I've always thought of this as a good thing, while others see it as a valid point of criticism. You'll have to decide for yourself.PHP is nice but Python is marriage materialPHP lacks stuff that you get in other languages like C# or JAVAYes it does. And general-purpose language X lack a lot of stuff that you get in PHP. Like being portable across operating systems AND across http servers, and support for every imaginable third party library that would be useful in a web development environment. You have to understand that PHP doesn't lack of anything important, if it did it would have died a long time ago. The comparison between general-purpose language X and other multi-purpose languages to PHP is a fallacy, apples and oranges. Although PHP offers some facilities to support the idea that it's general-purpose, it's not, it's a web language.You have to keep in mind that PHP's evolutionary path is quite different from general-purpose language X: PHP grew and evolved, it wasn't designed. Every time a feature is added to the language is out of actual necessity, not in accordance to some imaginary ideal of what  a language should be. Languages are first and foremost tools, and PHP is perfect as such.I don't have anything against general-purpose language X, I'm all for choosing the right tool for the job. I've always mixed and matched, and I'm coding in Java and Python too, sometimes in parallel with PHP. But PHP is the only one I'd ever consider marrying. :)If you're considering starting with PHP, you should of course start with the latest stable version, as you would in any other language.