Php Pros And Cons

For a description of PHP see PhpLanguage


Pros


Pro or Con depending on where you come from


Cons

  ...
  // Example PPAC-01
  if (true) {
$a = 1;  // assume this is a new variable $a
  }
  echo $a;  // in every other language but PHP, this is an invalid reference
  ...


Scoping Flaws

Regarding Example PPAC-01, this is part of the dynamic nature of PHP. I don't necessarily consider it a "flaw". Dynamic declaration is a design decision that has pros and cons. (Decent "lint" tools can point out suspicious usage, similar to a compiler.)

No it's not, it's a serious design flaw. The language designers barely know how to program -- and this is what you get when you let non-programmers design a programming language.

Braces, therefore, don't introduce new scopes. In fact, there is no way of introducing new scopes in PHP apart from function declarations, which as noted before, doesn't even work like you would expect.

Nested function declarations also don't do what you would expect since there are no local scopes. They are used explicitly for the side effect of declaring a new function in the global scope, which granted, can be useful for keeping the global scope clean since there's no namespaces. However, this is unnecessarily hobbled by the lack of lexical scoping, because there's no way to reference variables from outside the function declaration unless they're global:
  function foo($a) {
...
function bar() {
echo $a;  // $a is assumed to be a new variable; this echoes nothing.
}
  }
That's a bummer. I really miss Pascal-style nested function scope.

Work enough with PHP and you forget not to use it in other languages. It does make variables easy to spot, particularly constructions with variable variables and variable functions that would need some other syntactical construction if they didn't use it.


Addendum

Some people think that http://www.ukuug.org/events/linux2002/papers/html/php/index.html is a complete treatment of PHP's suitability for "non-trivial applications". The article, however, is full of misconceptions, a few of which need to be cleared up.

Conclusion The author needs to learn OOP and stop hacking in Perl.

OOP is over-sold.

OOP is under-comprehended, which leads to people concluding that it's over-sold. -- MarkTaylor 23 Oct 2004. Sorry, Mark, total nonsense. OOP is not a SilverBullet nor a GoldenHammer. It shall be superceded, and let us hope very soon.

If it is so darned hard to "get", that should count against it. How do you know that you don't "get" perl?


The online manual is widely regarded to be the best of any programming language.

For example http://www.php.net/strlen

Can you provide some data points here? I don't regard the PHP online manual to be anything special. I find many parts of it heavily underspecified; the user-contributed comments, when they aren't obsolete or flat-out wrong, are a pain to wade through. I can immediately think of at least two "online manuals" that I consider better than PHP's. One consists of the Java API documentation and the Java Language Specification; the other consists of the CommonLispHyperSpec (also known as CLHS, a densely hyperlinked online version of the Common Lisp ANSI specification) and the online version of GuySteele's "CommonLispTheLanguage", 2nd. edition (also known as CLtL2).

(to those, I'd add GrahamNelson's InformLanguage Designer Manual 4 at <http://www.inform-fiction.org/manual/html/index.html>, which is a joy - I am not overstating - to read)

Response: It's easy for a newbie to find the function he/she wants. But most of the comments ARE out of date. (this comment is out of date - most older / outdated PHP manual comments are being actively purged now. See the documentation mailing list to get a feel of activity: http://marc.theaimsgroup.com/?l=phpdoc. For an explanation of how to read the manual, try here: http://www.sitepoint.com/article/1262/2 )

In general, because the comments are constantly being removed, edited, updated, and folded back into the documentation, the online manual can be anywhere between "Horrible" to "Wonderful" depending on which section you are in, how experimental the extension is, and the phase of the moon.

'Hmm. Phunny, I have been using PHP for a number of server-side applications over the last few years (as of July 2011) and I find the online document support to be generally excellent. Perhaps I just haven't hit upon the foul-documented extension yet. Knock on wood.


A great intro rant about Php:

I can’t even say what’s wrong with PHP, because -— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.

You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.

You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you "well hey, what’s the problem with these tools? They’re all I’ve ever used and they work fine!" And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

That’s what’s wrong with PHP.

http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/


A counterpoint antirant:

The programming language many love to hate is experiencing a renaissance. This is not your parents’ PHP. The new PHP is a more mature language with community standards, a growing affinity for interoperable components, and a passionate movement to improve performance. If you have bypassed PHP for alternative languages, or if you are a PHP veteran unaware of recent changes, you owe it to yourself to give PHP a second look.

Language Features

PHP 5.5 (the latest stable build as of this writing) has made major progress from earlier versions. Recent PHP releases contain powerful new features and helpful developer tools, such as a built-in web server, generators for simpler iteration, and namespaces. With PHP 5.4, traits were introduced (a la Scala or Perl) to allow code reuse in single inheritance languages, as well as closures, which allow you to code PHP in a functional style. Other important features include the built-in FastCGI process manager and phpdbg debugger, and a new password hashing API that makes it easy to hash and securely manage passwords in PHP.

http://programming.oreilly.com/2014/03/the-new-php.html


We tend to take for granted features that quietly work relatively well. Our memories work better for "problem" features such that we tend to remember the bad parts but not the good. There are probably many functions and features in Php that do their job without drama that we are not giving Php credit for.


How is PhpLanguage compared to other scripting languages on a WindowsServerTwoThousandThree platform using a SqlServer database? Any articles or forums that discuss this type setup?

That is perhaps too specific a question for this wiki, which tends to focus more on concepts than specific product or product combinations.


See: SuccessHasBattleScars

CategoryPhp


EditText of this page (last edited June 18, 2014) or FindPage with title or text search