random1 Posted May 5, 2008 Share Posted May 5, 2008 Hi All, How do you compare floats in PHP? I am comparing browser versions and need to know how compare the following: $browserversion = "2.0.0.14"; // Firefox version $supportedversion = "2.0.0.00" // Minimum supported version of Firefox if($browserversion >= "2.0.0.00") { echo("Browser is supported"); } else { echo("Browser is not supported"); } I also need comparisons for Safari and Opera: e.g. if ($operaversion >= 9.0){echo("Opera version is supported...");} Link to comment https://forums.phpfreaks.com/topic/104128-comparing-floats-and-strings/ Share on other sites More sharing options...
Barand Posted May 5, 2008 Share Posted May 5, 2008 <?php $browserversion = "2.0.0.14"; // Firefox version $supportedversion = "2.0.0.00"; // Minimum supported version of Firefox if($browserversion >= $supportedversion) { echo "Browser is supported"; } else { echo "Browser is not supported"; } ?> gives--> Browser is supported So your problem is what exactly? Link to comment https://forums.phpfreaks.com/topic/104128-comparing-floats-and-strings/#findComment-533137 Share on other sites More sharing options...
random1 Posted May 5, 2008 Author Share Posted May 5, 2008 The problem is that this returns "Suported browser" regardless off how high or low the browser version is. Link to comment https://forums.phpfreaks.com/topic/104128-comparing-floats-and-strings/#findComment-533156 Share on other sites More sharing options...
Barand Posted May 5, 2008 Share Posted May 5, 2008 Not on my server <?php $browserversion = "2.0.0.14"; // Firefox version $supportedversion = "2.0.0.15"; // Minimum supported version of Firefox if($browserversion >= $supportedversion) { echo "Browser is supported"; } else { echo "Browser is not supported"; } ?> --> Browser is not supported Link to comment https://forums.phpfreaks.com/topic/104128-comparing-floats-and-strings/#findComment-533159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.