note 22179 deleted from function.phpversion by maxim
| From: | maxim@php.net | Date: | Wed, 14 Aug 2002 02:08:09 +0000 |
| Subject: | note 22179 deleted from function.phpversion by maxim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-34974@lists.php.net to get a copy of this message | ||
The above example is incorrect. It does not take the significance of each number into account, and
compares them as independent numbers. It also has the incorrect inequality operator for the action
it is trying to achieve.
I suggest using this instead:
# return True if given php version is the same as or older than the version currently running
function check_php_version ($version) {
$testSplit = explode ('.', $version);
$currentSplit = explode ('.', phpversion ());
if ($testSplit[0] < $currentSplit[0])
return True;
if ($testSplit[0] == $currentSplit[0]) {
if ($testSplit[1] < $currentSplit[1])
return True;
if ($testSplit[1] == $currentSplit[1]) {
if ($testSplit[2] <= $currentSplit[2])
return True;
}
}
return False;
}