PHP版本号数学[重复]

This question already has an answer here:

I am working on a project where I can have different versions of the client and want to be able to do > and < math on the version numbers. The issue is the version numbers are something like 0.5.1.

The question is, is there anyway in PHP to do some sort of version number math where it is able to understand that type of numbering system?

</div>

Use PHP's built-in function version_compare() for that.

From the documentation page:

By default, version_compare() returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower.

Example:

<?php
if (version_compare(PHP_VERSION, '6.0.0') >= 0) {
    echo 'I am at least PHP version 6.0.0, my version: ' . PHP_VERSION . "
";
}

if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
    echo 'I am at least PHP version 5.3.0, my version: ' . PHP_VERSION . "
";
}

if (version_compare(PHP_VERSION, '5.0.0', '>=')) {
    echo 'I am using PHP 5, my version: ' . PHP_VERSION . "
";
}

if (version_compare(PHP_VERSION, '5.0.0', '<')) {
    echo 'I am using PHP 4, my version: ' . PHP_VERSION . "
";
}
?>

(taken from the documentation page)

I hope this helps. Good luck! :)