如果版本大于1.5.1.3,则进行Opencart测试

问题描述:

How would I add an IF statement to check if the opencart version is greater than 1.5.1.3?

This is defined in the index.php as:

// Version
define('VERSION', '1.5.0');

I have tried: if((int)VERSION >= '1.5.1.3'){ although when I convert this into an int it becomes empty.

Also I tried this with the same effect:

$this->data['oc_version'] = (int)str_replace('.', '', VERSION);
if($this->data['oc_version'] >= 1513){

Do I need to convert this into an int to correctly perform greater/less than calculations?

如何添加IF语句以检查opencart版本是否大于1.5.1.3? p>

这在index.php中定义为: p>

  // Version 
define('VERSION','1.5.0'); 
   code>  pre> 
 
 

我试过: if((int)VERSION> ='1.5.1.3'){ code>虽然我把它转换为int 它变得空虚。 p>

我也尝试了同样的效果: p>

  $ this-> data ['oc_version'] =(int)str_replace  ('。','',VERSION); 
if($ this-> data ['oc_version']> = 1513){
  code>  pre> 
 
 

我是否 需要将其转换为int以正确执行大于/小于计算? p> div>

if(version_compare(VERSION, '1.5.1.3', '>')) {
    // CODE HERE IF HIGHER
} else {
    // CODE HERE IF LOWER
}

Though the 1.5.1.3 branch actually goes up to 1.5.1.3.1 so I'm guessing you want it to be that

I tried this recently and couldnt get it working as above, perhaps its a PHP version thing but I got it working with:

if(version_compare(VERSION, '1.5.1.3') > 0) {
    // CODE HERE IF HIGHER
} else {
    // CODE HERE IF LOWER
}

Hope that helps someone else. Got the code from here: http://us2.php.net/manual/en/function.version-compare.php