PHP version_compare () function, phpversion_compare. The PHP version determines the version_compare () function, and phpversion_compare simply finds out in Du Niang to determine whether the current PHP version is higher than a specific version, or, if the PHP version is earlier than a certain version, determine the version_compare () function, and phpversion_compare
The method of checking whether the current PHP version is higher than a certain version or earlier than a certain version is simply found by du Niang.
The display results are basically the same. well, if I hadn't forgotten version_compare (), I wouldn't go to du Niang to find the previous code.
The version_compare () function is described in the php manual as follows:
Version_compare () is used to compare two "PHP normalization" version numeric strings. This is helpful for compiling programs that are only compatible with some versions of PHP.
Mixed version_compare (string$version1, String$version2[, String$operator])
Return hybrid type
String $ version1-version 1 is required
String $ version2-Version 2 is required
String $ operator-optional for operators
That is<,Lt,<=,Le,>,Gt,> =,Ge,=,=,Eq,! =,<>AndNe.
If the third parameter is specified, the return value is boolean. if the third parameter is not specified, the following three conditions are returned:
When the first version is earlier than the second version, return-1
When the first version is equal to the second version, return 0
When the first version is earlier than the second version, return 1
'; // The Current PHP version is '. PHP_VERSION. "\ n"; var_dump (version_compare (PHP_VERSION, '5. 2.0 '); var_dump (version_compare (PHP_VERSION, '5. 2.0 ',' = '); var_dump (version_compare (PHP_VERSION, '5. 3.0 ', 'ge'); if (version_compare (PHP_VERSION, '5. 3.0 ', 'ge') {echo' your PHP version is later than 5.3.0, and the current version is '. PHP_VERSION;} else {echo 'Your PHP version is earlier than 5.3.0, and the current version is '. PHP_VERSION ;}
The result is as follows:
The current PHP version is 5.2.17int (1) bool (false). Your PHP version is earlier than 5.3.0, and the current version is 5.2.17.
Http://www.bkjia.com/PHPjc/916825.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/916825.htmlTechArticlePHP version judge version_compare () function, phpversion_compare in the degree of simple find the next, to determine whether the current PHP version is higher than a version, or less than a version of the method...