13

I have to find out the earliest PHP4 version my code will run under (I already know it runs on PHP5 and on PHP 4.4.9 (the last PHP4 version -- included in MAMP).

Are there code inspection tools that will do this? Do I need to install each PHP version and see what happens :-)

1

5 Answers 5

23

There is a PEAR package in the bartlett.laurent-laville.org channel for this: PHP_CompatInfo

Find out the minimum version and the extensions required for a piece of code to run

Examples could be found here.

Note: The original PEAR package is for PHP4 only, and is no longer maintained.

1
  • This is a great answer, but I would also suggest after you find out that version, take Cassy's advice and use an install of that PHP and verify that version really works.
    – TravisO
    Dec 18, 2009 at 0:56
0

I don't think there is a tool for that. I guess you don't have to install all PHP version, try major releases, like 4.1, 4.2, 4.3, etc To my mind minor releases don't have language syntax changes or anything major, usually it's bug fixes

0

Before you manually download and install various versions of PHP, try to download the XAMPP versions, that have the old php binaries packaged:

Download links on oldapps.com

1
  • I think the best answer is to use the Pear component but it would be wise to then take that min version via XAMPP and actually verify the code works.
    – TravisO
    Dec 18, 2009 at 0:55
0

I use (unit) tests for this purpose.

for v in $versions; do
  php$v -f tests.php
done
0

PHPCompatibility is a tool that runs on top of PHP_CodeSniffer and let's you check your code against compatibility with PHP 5-8.

As of 2023-09 you should use the development branch because the latest tag is from 2019.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.