PHP version Judge Version_compare () function, Phpversion_compare
In the degree Niang simple to find the next, to determine whether the current version of PHP is higher than a version, or lower than a version of the method
The results are basically the same, okay, if I didn't forget version_compare () This function I'm not going to look for the Niang, determined to find the previous code
The PHP manual describes the Version_compare () function in the following way:
Version_compare () is used to compare two "php normalized" version number strings. This is useful for writing programs that can only be compatible with certain versions of PHP
Mixed Version_compare ( string $version1 , string $version2 [, string $operator ])
Back to Mixed type
String $version 1-Version 1 required
String $version 2-Version 2 required
String $operator-understood as operator bar optional
i.e. <,lt,<=, le,>, gt,>=, ge, = =, =,eq,! =,<> and ne.
If the third argument is specified, a Boolean is returned, and if no third parameter is specified, the following three kinds of cases are returned:
When the first version is lower than the second version return-1
Return 0 when the first version equals the second version
Return 1 when the first version is less than the second version
'; I am using the version 5.2.17echo ' php current 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 greater than 5.3.0, The current version is '. Php_version;} Else{echo ' Your PHP version is less than 5.3.0, the current version is '. Php_version;}
The results are as follows:
5.2. - Int (1) bool(False) bool (false) your PHP version is less than 5. 3.0 5.2. -
http://www.bkjia.com/PHPjc/916825.html www.bkjia.com true http://www.bkjia.com/PHPjc/916825.html techarticle PHP version to determine the Version_compare () function, phpversion_compare in the degree Niang simple to find the next, to determine whether the current version of PHP is higher than a version, or less than a version of the method ...