Source code for file /phpxmlrpc/compat/version_compare.php
Documentation is available at version_compare.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// $Id: version_compare.php,v 1.1 2005/07/11 16:34:36 ggiunta Exp $
* Replace version_compare()
* @link http://php.net/function.version_compare
* @version $Revision: 1.1 $
* @require PHP 4.0.0 (user_error)
user_error('version_compare() expects parameter 1 to be string, ' .
gettype($version1) .
' given', E_USER_WARNING);
user_error('version_compare() expects parameter 2 to be string, ' .
gettype($version2) .
' given', E_USER_WARNING);
user_error('version_compare() expects parameter 3 to be string, ' .
gettype($operator) .
' given', E_USER_WARNING);
// Replace empty entries at the start of the array
// '#' stands for any number
// Loop through each segment in the version string
if ($v1[$i] ==
$v2[$i]) {
$compare =
($i1 <
$i2) ? -
1 :
1;
// We use the position of '#' in the versions list
// for numbers... (so take care of # in original string)
if (isset
($versions[$i1]) && isset
($versions[$i2])) {
$compare =
($versions[$i1] <
$versions[$i2]) ? -
1 :
1;
} elseif (isset
($versions[$i1])) {
} elseif (isset
($versions[$i2])) {
// If previous loop didn't find anything, compare the "extra" segments
if (isset
($versions[$v2[$i]])) {
$compare =
($versions[$v2[$i]] <
4) ?
1 : -
1;
if (isset
($versions[$v1[$i]])) {
$compare =
($versions[$v1[$i]] <
4) ? -
1 :
1;
return (bool)
($compare >
0);
return (bool)
($compare >=
0);
return (bool)
($compare <=
0);
return (bool)
($compare ==
0);
return (bool)
($compare !=
0);
return (bool)
($compare <
0);