note 22148 modified in function.phpversion by maxim
| From: | maxim@php.net | Date: | Fri, 16 May 2003 02:03:14 +0000 |
| Subject: | note 22148 modified in function.phpversion by maxim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48090@lists.php.net to get a copy of this message | ||
This function will return true if the specified version is older than the version the server is
running.
ex:
if(version_check('4.1.0')) die("PHP version 4.1.0 or greater is required.");
function version_check($vercheck)
{
$minver = explode(".", $vercheck);
$curver = explode(".", phpversion());
if(($curver[0] <= $minver[0]) && ($curver[1] <= $minver[1]) && ($curver[1]
<= $minver[1]) && ($curver[2][0] < $minver[2][0])) return true;
else return false;
}
Editor's Note:
.....................
Alternatively, you might want to check `version_compare()' function that does exactly this.
--was--
This function will return true if the specified version is older than the version the server is
running.
ex:
if(version_check('4.1.0')) die("PHP version 4.1.0 or greater is required.");
function version_check($vercheck)
{
$minver = explode(".", $vercheck);
$curver = explode(".", phpversion());
if(($curver[0] <= $minver[0]) && ($curver[1] <= $minver[1]) && ($curver[1]
<= $minver[1]) && ($curver[2][0] < $minver[2][0])) return true;
else return false;
}
http://www.php.net/manual/en/function.phpversion.php