PHP code example of steevanb / version-comparator

1. Go to this page and download the library: Download steevanb/version-comparator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

steevanb / version-comparator example snippets


PhpVersionComparator::isBetween('8', '9'); // return true is PHP is >= 8.0.0 and < 9.0.0
PhpVersionComparator::isBetween('8.0', '8.1'); // return true is PHP is >= 8.0.0 and < 8.1.0
PhpVersionComparator::isBetween('8.0.0', '8.0.2'); // return true is PHP is >= 8.0.0 and < 8.0.2

// For PHP 5.3 to 5.6 
PhpVersionComparator::isPhp5(); // return true is PHP is >= 5.0.0 and < 6.0.0
PhpVersionComparator::isPhp53(); // return true is PHP is >= 5.3.0 and < 5.4.0
PhpVersionComparator::isPhp54(); // return true is PHP is >= 5.4.0 and < 5.5.0
PhpVersionComparator::isPhp55(); // return true is PHP is >= 5.5.0 and < 5.6.0
PhpVersionComparator::isPhp56(); // return true is PHP is >= 5.6.0 and < 5.7.0

// For PHP 7.0 to 7.4
PhpVersionComparator::isPhp7(); // return true is PHP is >= 7.0.0 and < 8.0.0
PhpVersionComparator::isPhp70(); // return true is PHP is >= 7.0.0 and < 7.1.0
PhpVersionComparator::isPhp71(); // return true is PHP is >= 7.1.0 and < 7.2.0
PhpVersionComparator::isPhp72(); // return true is PHP is >= 7.2.0 and < 7.3.0
PhpVersionComparator::isPhp73(); // return true is PHP is >= 7.3.0 and < 7.4.0
PhpVersionComparator::isPhp74(); // return true is PHP is >= 7.4.0 and < 7.5.0

// For PHP 8.0 to latest 8.x
PhpVersionComparator::isPhp8(); // return true is PHP is >= 8.0.0 and < 9.0.0
PhpVersionComparator::isPhp80(); // return true is PHP is >= 8.0.0 and < 8.1.0
PhpVersionComparator::isPhp81(); // return true is PHP is >= 8.1.0 and < 8.2.0

PhpVersionComparator::assertIsBetween('8', '9');
PhpVersionComparator::assertIsPhp5();
// etc