Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a PHP 5.2 'compatibility mode' for PHP 5.3?

Tags:

php

wordpress

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.

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?

like image 904
James Avatar asked Jul 22 '11 14:07

James


People also ask

Is PHP backwards compatible?

php has no backward compatibility in all version. It often removed some functions when it changed version. The problem occurs when you have to upgrade server and need to change php version but some php scripts no longer work with new php version. You also have to correct php script which is a bigger job.

What is included in PHP in function with the release of PHP 5.2 1 version?

Many improvements and enhancements to the filter and zip extensions. Memory limit is now always enabled, this includes Windows builds, with a default limit of 128 megabytes. Added several performance optimizations using faster Win32 APIs (this change means that PHP no longer supports Windows 98).

What was the PHP version before the PHP7?

PHP 7 is an improved version of PHP 5 that provides faster performance while using less storage. PHP5 coding is much simpler than traditional coding, and PHP 7 provides developers with a simple coding system. The upgraded PHP7 engine is regarded as a next-generation design.


1 Answers

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.

like image 73
Artefacto Avatar answered Oct 29 '22 07:10

Artefacto