PHP version version_compare () function, phpversion_compare_PHP tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.