note 58145 deleted from function.phpversion by derick
| From: | derick@php.net | Date: | Fri, 04 Aug 2006 13:20:07 +0000 |
| Subject: | note 58145 deleted from function.phpversion by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-115547@lists.php.net to get a copy of this message | ||
Note Submitter:
----
The version 4.3.10-16 does not "respect" the requiement for the above code. Use this
fuction.
sample call:
if(!check_version(PHP_VERSION, "4.1.0") )
{
echo 'Current PHP version: ' . PHP_VERSION . ' is too low for this
code!<p>';
}
Function:
# Compares versions of software
# versions must must use the format ' x.y.z... '
# where (x, y, z) are numbers in [0-9]
function check_version($currentversion, $requiredversion)
{
list($majorC, $minorC, $editC) = split('[/.-]', $currentversion);
list($majorR, $minorR, $editR) = split('[/.-]', $requiredversion);
if ($majorC > $majorR) return true;
if ($majorC < $majorR) return false;
// same major - check ninor
if ($minorC > $minorR) return true;
if ($minorC < $minorR) return false;
// and same minor
if ($editC >= $editR) return true;
return false;
}