/** * Find if a version is minor or greater than a given PHP version * (it should be red as "if my php version is minor|greater|between this one) * * Usage: * PEAR::phpVersionIs('4.0.7') => if the current version * is minor than version 4.0.7 * PEAR::phpVersionIs(null, '4.0.12pl3') => if current is greater that 4.0.12pl3 * PEAR::phpVersionIs('4.0.9', '4.0.4') => if current is between 4.0.9 and 4.0.4 * * @param string $minorthan Version should be minor than this param * @param string $greaterthan Version should be greater than this param * @param string $version Version to compare with (defaults to current) * * @return bool If the comparation was successful or not */ function phpVersionIs($minorthan = null, $greaterthan = null, $version = PHP_VERSION) { $version = PEAR::_explodePHPVersion($version); $ret = false; if ($minorthan) { $minor = PEAR::_explodePHPVersion($minorthan); for ($i = 0; $i < count($version) - 1 and $minor[$i] == $version[$i]; $i++) { } if ($version[$i] >= $minor[$i]) { return false; } $ret = true; } if ($greaterthan) { $greater = PEAR::_explodePHPVersion($greaterthan); for ($i = 0; $i < count($version) - 1 and $greater[$i] == $version[$i]; $i++) { } $ret = $version[$i] > $greater[$i] ? true : false; } return $ret; }