note 22183 deleted from function.phpversion by nlopess
| From: | nlopess@php.net | Date: | Thu, 26 Feb 2004 16:36:22 +0000 |
| Subject: | note 22183 deleted from function.phpversion by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65807@lists.php.net to get a copy of this message | ||
Note Submitter: interfear01 at hotmail dot com
----
The above example made on 07-Jun-2002 does not take into account the significance of each number,
instead it considers them as independant values. The incorrect inequality operators are also used
to achieve the stated task.
instead I suggest this:
# 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;
}