PHP 5.3: The Good, the Bad and the Ugly

PHP 5.3 was released today; here are my positive and negatives:

The Good: Closures

Anonymous functions created with create_function have always been a bit messy. With 5.3 comes support for closures with a much cleaner syntax:

    $greet = function($name)
    {
        printf("Hello %s\r\n", $name);
    };

    $greet('World');
    $greet('PHP');

The Bad: Backwards incompatible changes

Although not a massive change from 5.2, there are enough differences to break existing code.

The Ugly: Namespaces

There has been quite a discussion about PHP’s new namespace syntax.

$c = new \my\name\MyClass;

It’s just damn ugly. The more sensible choice, :: is already used as the scope resolution operator and was therefore dismissed.

Glen Scott

I’m a freelance software developer with 18 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork. I am the Managing Director of Yellow Square Development.

More Posts

Follow Me:
TwitterFacebookLinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.