If you're careful, this function actualy works quite nicely for comparing version numbers from programs other than PHP itself. I've used it to compare MySQL version numbers. The only issue is that version_compare doesn't recognize the 'gamma' addition that mysql uses as being later than 'alpha' or 'beta', because the latter two are treated specially. If you keep this in mind though, you should have no problems.

<?php
//Compare two sets of versions, where major/minor/etc. releases are separated by dots.
//Returns 0 if both are equal, 1 if A > B, and -1 if B < A.
function version_compare2($a, $b)
{
$a = explode(".", rtrim($a, ".0")); //Split version into pieces and remove trailing .0
$b = explode(".", rtrim($b, ".0")); //Split version into pieces and remove trailing .0
foreach ($a as $depth => $aVal)
{ //Iterate over each piece of A
if (isset($b[$depth]))
{ //If B matches A to this depth, compare the values
if ($aVal > $b[$depth]) return 1; //Return A > B
else if ($aVal < $b[$depth]) return -1; //Return B > A
//An equal result is inconclusive at this point
}
else
{ //If B does not match A to this depth, then A comes after B in sort order
return 1; //so return A > B
}
}
//At this point, we know that to the depth that A and B extend to, they are equivalent.
//Either the loop ended because A is shorter than B, or both are equal.
return (count($a) < count($b)) ? -1 : 0;
}
?>

What PHP.net page is any good without a classy userland implementation of a function already provided by PHP? Generally, there are pseudo-benchmarks and reasons why you'd want to use their "far superior" implementations.

Since exit is a difficult construct to implement, and exit cannot be called using variable functions, this function is <blink>BETTER</blink>.

While you cannot use this code without parentheses, you'll find that this exit function improves your site's performance with at least 25 teraflops of flux computing power!

I used to be a fan of die;, I even tried to use exit;, but now; I'm a true-blue userland_exit() fan, now with 20% more.*

I know this is somewhat incomplete, but it did a fair enough job for what I needed. I was writing some code that needed done immediately on a server that was to be upgraded some time in the future. Here is a quick replacement for version_compare (without the use of the operator argument). Feel free to add to this / complete it.

It also uses phpversion() as a default version if only one string is present. It can make your code look nicer 'cuz you can now write:<?php if (ver_cmp($version1, '>=', $version2)) something; ?>and to check a version string against the PHP's version you might use:<?php if (ver_cmp('>=', $version)) something; ?>instead of using phpversion().