For a look at both sides of the argument in one place, see: PhpProsAndCons
- Both 'sides' of WhyWeLovePhp.
PHP is a notably simple language: the effort of learning PhpLanguage is trivial if you already know CeeLanguage or CeePlusPlus. It now provides a class system very like C++'s. Database and web integration are unusually strong. Cross-platform support and the availability of languages are excellent. PHP has good RegularExpressions and AnonymousFunctions.
Compared to PerlLanguage, PHP is much simpler.
Compared to PythonLanguage, PHP is much more C-like. But since when was being "much more C-like" an advantage, and if it is, then why aren't you simply using C? Python's advantage over PHP is that it's "much more LispLanguage-like", having closures, sensible scoping rules, etc. Being "much more C-like" sounds like a big step backwards.
-
I think what is meant is that one probably knows C-like syntax from at least one other language they've encountered. Maybe it would not be C, but Java or JavaScript or C#, etc. Thus, ease of learning is implied. How to make blocks, functions, IF statements, and loops is already known for the most part such that one can focus on learning other differences.
-
What's often preferred is some form of "dynamic C": C's syntax but with dynamic typing and dynamic declarations of some sort. C-style syntax is the Langua Franca. As far as whether it's the "best" syntax style, perhaps consider ItsTimeToDumpCeeSyntax.
Compared to RubyLanguage, PHP is both much more C-like and has much stronger support on non-Unix platforms.
Compared to all of the above, PHP arguably has much simpler webpage integration, and programmers are easier to find (with the possible exception of Perl). However, the other 3 big scripting languages may still have advantages that make them more suitable for "heavy lifting" non-website jobs.
- Really? Could you give examples?
- You can mix PHP and HTML both bottom-up and top-bottom. Either start with raw HTML and sprinkle PHP here and there using <? and <?= (in effect turning it into a template) or output HTML from PHP in the usual echo/sprintf() way. Both of those uses have their right (and wrong) place.--DexenDeVries
I love being able to edit a script into place using any editing tool on any platform, move it to my Apache server, and have it execute as soon as the file permissions are set. Just far and away too cool. Changes on the fly? No problem!
PHP provides a handy way of packing a bunch of variables for passing them around as single unit (an associative array), with little performance penalty. It leaves more freedom than using pre-defined structures with explicitly enumerated fields. Check out PHP manual for compact() and extract() functions. --DexenDeVries
and parse_str() and http_build_query()