开发者

Should I upgrade my server's PHP to version 5.3?

I have php 5.2.11 on my server. Should I upgrade to the new PHP 5.3.2?

Any new feat开发者_JS百科ures which can save my life?

Any suggesstions?


The most notable thing is that 5.3 is faster. How much depends on your system and code, many people say it's notable.

The migration guide on http://php.net/migration53 documents changes and new features. I personally like closures/anonymous functions a lot.


Late static binding has been the first thing which I've actually used of 5.3. Lambdas and namespaces are great, but you were able to work around their absence in prior versions.

LSB, in short, lets you access the class which was actually called when calling static functions.

<?php
class A {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        static::who(); // Here comes Late Static Bindings
    }
}

class B extends A {
    public static function who() {
        echo __CLASS__;
    }
}

B::test(); // "B"

AFAIK, there was no way to do this in PHP < 5.3


I would be wary of upgrading if you are running applications not written by yourself, as you may find lots of warnings being thrown up, 5.3 is much fussier.


I find the lambda functions very useful, especially together with array_search, array_map, array_reduce et al.


Take a look at 'changelog' and give your desicion if you really need it.


Upgrading to PHP 5.3 is definitely a good idea, but only if your code is PHP 5.3 compatible.

You can automate part of that testing by using the PHP 5.3 Compatibility codesniffer rules - code that passes this isn't necessarily going to work 100%, but at least you'll no longer have to worry about a lot of issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜