How do version numbers work in PHP, and why is 7.0.10 considered higher than 7.0.2 and 7.0.1?

In PHP, version numbers are typically in the format of major.minor.patch. When comparing version numbers, each segment is compared from left to right. In this case, 7.0.10 is considered higher than 7.0.2 and 7.0.1 because the patch version (10) is greater than both 2 and 1.

$version1 = '7.0.2';
$version2 = '7.0.10';

if (version_compare($version1, $version2, '<')) {
    echo "$version1 is lower than $version2";
} else {
    echo "$version1 is higher than $version2";
}