How to compares two PHP-standardized version number strings using version_compare() in PHP

2 Answers

0 votes
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
    echo 'PHP 8.0.0 or later, my version is: ' . PHP_VERSION;
}
   
   
    
   
/*
run: 
   
PHP 8.0.0 or later, my version is: 8.0.13
   
*/

 



answered Jul 23, 2016 by avibootz
edited Jul 8, 2023 by avibootz
0 votes
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
    echo 'PHP 8.0.0 or later' . "\n";
} else {
     echo 'PHP version is not less than 8.0.0' . "\n";
}

echo 'My PHP version is: ' . PHP_VERSION;
   
   
    
   
/*
run: 
   
PHP version is not less than 8.0.0
My PHP version is: 8.0.13
   
*/

 



answered Jul 8, 2023 by avibootz
...