Return to Snippet

Revision: 17295
at August 30, 2009 22:07 by kirik


Initial Code
function phpMinV($v)
{
	$phpV = PHP_VERSION;

	if ($phpV[0] >= $v[0]) {
		if (empty($v[2]) || $v[2] == '*') {
			return true;
		} elseif ($phpV[2] >= $v[2]) {
			if (empty($v[4]) || $v[4] == '*' || $phpV[4] >= $v[4]) {
				return true;
			}
		}
	}

	return false;
}


/* ---- Newer than 4 ---- */
if (phpMinV('4')) {
	// .....
}
// or
if (phpMinV('4.*')) {
	// .....
}

/* ---- Newer than 5.1 ---- */
if (phpMinV('5.1')) {
	// .....
}
// or
if (phpMinV('5.1.*')) {
	// .....
}

/* ---- Newer than 5.2.3 ---- */
if (phpMinV('5.2.3')) {
	// .....
}

Initial URL

                                

Initial Description
Easy check (:

**UPD**
You can just use [version_compare()](http://ca.php.net/manual/en/function.version-compare.php)  function.

Initial Title
Check minimum version of PHP

Initial Tags
php

Initial Language
PHP