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.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>