简体   繁体   中英

PHP version Check

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'];   

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM