PHP code example of valorin / debver

1. Go to this page and download the library: Download valorin/debver 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/ */

    

valorin / debver example snippets



namespace YourApplication;
use Debver\Version;

$version1 = "5.1.2-1ubuntu3.9";
$version2 = "3.9.4-4ubuntu0.2";

$compare = Version::compare($version1, $version2);

$result = Version::compare($version1, $version2);

if ($result == -1) {
    echo "{$version1} < {$version2}";
} elseif ($result == 0) {
    echo "{$version1} == {$version2}";
} elseif ($result == 1) {
    echo "{$version1} > {$version2}";
}

$version = new Version($version1);

$epoch    = $version->getEpoch();
$upstream = $version->getUpstream();
$revision = $version->getRevision();

$result = Version::compareWithDpkg($version1, $version2);

if ($result == -1) {
    echo "{$version1} < {$version2}";
} elseif ($result == 0) {
    echo "{$version1} == {$version2}";
} elseif ($result == 1) {
    echo "{$version1} > {$version2}";
}

$string = Version::getCompareString($version);