Documentation

CheckVersion

bool
CheckVersion(
 string version1,
 string version2
);

The function compares versions in formats XX.XX.XX. Returns 'true', if the version number passed in the version1 parameter is higher or equal to the second version, passed in the version2 parameter. Otherwise, returns false.

Function parameters

ParameterDescription
version1 First version in the "XX.XX.XX" format
version2 Second version in the "XX.XX.XX" format

Examples of use

<?
$ver1 = "3.0.15";
$ver2 = "4.0.0";

$res = CheckVersion($ver1, $ver2);

echo ($res) ? $ver1." >= ".$ver2 : $ver1." < ".$ver2; 

// result: 3.0.15 < 4.0.0
?>


© «Bitrix24», 2001-2024
Up