note 34938 added to function.phpversion

From: Date: Tue, 12 Aug 2003 15:32:12 +0000
Subject: note 34938 added to function.phpversion
Groups: php.notes 
Request: Send a blank email to php-notes+get-54023@lists.php.net to get a copy of this message
this a good work around if haven't got version compare will be working on a better way of profileing the versions function version_compare($Ver1,$Ver2,$TEST = "") { $Profile1 = 0; $Profile2 = 0; $Ver1 = explode(".",$Ver1); $Ver2 = explode(".",$Ver2); if($Ver1[0] != $Ver2[0]) { if($Ver1[0] > $Ver2[0]) { $Profile1 += 100; $Profile2 -= 100; } else { $Profile2 += 100; $Profile1 -= 100; } } if($Ver1[1] != $Ver2[1]) { if($Ver1[1] > $Ver2[1]) { $Profile1 += 10; $Profile2 -= 10; } else { $Profile2 += 10; $Profile1 -= 10; } } if($Ver1[2] != $Ver2[2]) { if($Ver1[2] > $Ver2[2]) { $Profile1 += 1; $Profile2 -= 1; } else { $Profile2 += 1; $Profile1 -= 1; } } switch($TEST) { case "<": case "lt": return ($Profile1 < $Profile2)?1:0; break; case "<=": case "le": return ($Profile1 <= $Profile2)?1:0; break; case ">": case "gt": return ($Profile1 > $Profile2)?1:0; break; case ">=": case "ge": return ($Profile1 >= $Profile2)?1:0; break; case "==": case "=": case "eq": return ($Profile1 == $Profile2)?1:0; break; case "!=": case "<>": case "ne": return ($Profile1 != $Profile2)?1:0; break; default: if($Profile1 == $Profile2)return 0; if($Profile1 > $Profile2)return 1; if($Profile1 < $Profile2)return -1; break; } } ---- Manual Page -- http://www.php.net/manual/en/function.phpversion.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34938 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34938&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34938&report=yes

« previous php.notes (#54023) next »