Is there a PHP 5.2 ‘compatibility mode’ for PHP 5.3?

I’m currently developing a WordPress plugin. I just became aware of the fact that most major WordPress hosting environments are still using PHP 5.2. Given the fact that security patches for 5.2 are still being released despite the fact 5.2 is no longer officially supported, it very much looks like 5.2 isn’t going anywhere soon.

So it looks like I’ll need to do some refactoring where I’ve made use of a few 5.3 features, namely late static binding and closures.

Read More

Ideally I don’t want to totally trash my 5.3 environment just to install a 5.2 one. Is there some way to set a ‘compatibility mode’ for my 5.3 setup so it only accepts valid 5.2 syntax?

Related posts

Leave a Reply

1 comment

  1. There’s no way to do this, you’ll have to install 5.2.

    If you can live with catching only syntax level incompatibilities (static::, lambda functions, goto, …), then you can have a 5.2 binary in an isolated location and run the syntax check on the files (php -l) as a build step. You won’t get warned of usage of the new functions, new arguments, etc. though.