version_compare比较php的版本
/**
* Compares two "PHP-standardized" version number strings
* @link https://php.net/manual/en/function.version-compare.php
* @param string $version1 <p>
* First version number.
* </p>
* @param string $version2 <p>
* Second version number.
* </p>
* @param string $operator [optional] <p>
* If you specify the third optional operator
* argument, you can test for a particular relationship. The
* possible operators are: <,
* lt, <=,
* le, >,
* gt, >=,
* ge, ==,
* =, eq,
* !=, <>,
* ne respectively.
* </p>
* <p>
* This parameter is case-sensitive, so values should be lowercase.
* </p>
* @return int|bool 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.
* </p>
* <p>
* When using the optional operator argument, the
* function will return true if the relationship is the one specified
* by the operator, false otherwise.
*/
function version_compare($version1, $version2, $operator = null) { }
示例:
var_dump(PHP_VERSION);//string(5) "7.3.4"
$result = version_compare('7.3.0', PHP_VERSION, '<');
var_dump($result);//bool(true)
$result = version_compare('7.3.0', PHP_VERSION, '>');
var_dump($result);//bool(false)