PHP version Check

Scott Source

So I'm basically trying to create a tool that used across platforms, including sometimes legacy php version.

I don't plan on supporting anything less than 5.4 so I'd like to use something like below; however, instead of the application dying, I get various syntax errors. One of the first to start alerting is using brackets to define arrays.

Is there anyway to get around this?

if (version_compare(phpversion(), '5.4', '<')) {
    die('This tool does not support anything < PHP 5.4<br>Your PHP version is: '.phpversion() );

$array= ['a','b','c'];   


answered 1 week ago Evert #1

The file you are doing a version_check for should simply not use any newer PHP features or include any files that do. If you want the version_check to work on PHP 4, it can only use PHP 4 features.

comments powered by Disqus