note 23562 added to function.version-compare
| From: | webmaster at mgs2online dot f2s dot com | Date: | Mon, 22 Jul 2002 22:23:53 +0000 |
| Subject: | note 23562 added to function.version-compare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33387@lists.php.net to get a copy of this message | ||
you do not need all those tests. Try some code like this:
<?php
function minimum_version($vercheck)
{
$minver = (int)str_replace('.', '', $vercheck);
$curver = (int)str_replace('.', '', phpversion());
if($curver >= $minver)
return true;
return false;
}
if (!minimum_version('4.1.1'))
print 'Minimum version not met.';
else
print 'You\'re in!';
?>
Simply remove the dots and cast to an integer.
--
http://www.php.net/manual/en/function.version-compare.php
http://master.php.net/manage/user-notes.php?action=edit+23562
http://master.php.net/manage/user-notes.php?action=delete+23562
http://master.php.net/manage/user-notes.php?action=reject+23562