PHP 6.0: More to Love, Less to Hate

by Ostatic Staff - May. 15, 2008

Programmers are snobs. Not all of us, mind you, but many of us. If you're not convinced, ask a programmer what programming language he or she uses. And then ask them what they think of another language -- say, C, or Java, or Perl, or Ruby. Almost inevitably, the programmer who has only good things to say about his or her favorite language will have nothing good to say about many of the other languages you mention.

Perhaps I'm exaggerating a bit here; the fact is that most modern programmers need to use a few different languages. Web developers, for example, typically need to know not just one main programming language, but also SQL (for communication with the database) and JavaScript (for client-side applications). But people still have the languages that they love, as well as those that they love to hate.

As I wrote a few days ago, one of the languages that many people love to hate is PHP. What started out as a simple templating language written in Perl has become one of the biggest open source success stories. PHP might theoretically be a general-purpose programming language, but in practice, it is used almost exclusively for creating Web applications.

PHP is extremely popular: It runs under many operating systems, and many Web servers has dozens of modules that add to its capabilities. More than that, PHP programs execute quickly, without using a lot of memory. Contrast that with Ruby on Rails, which everyone admits runs slowly and uses too much memory. Java might give you similar or better performance, but PHP has a far shallower learning curve, making it easy to write some code and put it online.

That said, there are reasons for programmers to turn their noses up at PHP. Among the biggest have been:

  • PHP puts all functions and variables into a single global "namespace." Imagine a world without last names, and you can begin to see what the problem would be: If two different programmers decide to use the same variable name, they might trample on one another, with disastrous results. PHP 6.0 will introduce namespaces, making it possible to have two size() functions, or $username variables.
  • PHP can grab variables from the surrounding environment, including the HTTP request, using its "register_globals" function. This has been highly discouraged for a long time, and is off by default in recent versions of PHP. Version 6.0 will remove it. Several other functions, similarly outdated and potentially dangerous, have also been removed from this release.
  • PHP's support for Unicode has been historically weak. Unicode is a method for describing all of the characters in the languages of the world, and thus opens the door to truly international applications. The computer world has been moving toward Unicode over the last decade, and languages that don't support it will find themselves increasingly unusable. PHP 6.0 includes a great deal of support for Unicode, creating a distinction between "bytes" and "characters" that's necessary when you need more than 8 bits.

Over the last few days, there has been a flurry of writing about PHP 6.0, which will be released in the near future. Part of the reason is the fact that many older programs will fail to run under PHP 6.0 without some retooling. But another reason is that the open source community encourages its members to upgrade, while providing support and preparations for that upgrade in order to make it as smooth as possible.

And of course, because PHP is open source software, you don't need to wait for an official release date in order to try it out. You can just go to, and download the latest developer snapshot. If you run any serious sites that use PHP, you would be wise to run such tests, not just to help your own site, but to give feedback to the PHP developers before the release is official.

PHP still has features and quirks that will continue to irk some programmers. But as PHP 6.0 comes closer to its final release, it seems safe to say that this new release will have more to love, and much less to hate.