20 Jul 2012 22:57
Re: [PHP-DEV] common issue with version_compare()
Andrew Faulds <ajfweb <at> googlemail.com>
2012-07-20 20:57:32 GMT
2012-07-20 20:57:32 GMT
Well, in the spirit of PHP, let's make version_compare_fixed()! On Jul 20, 2012 1:41 PM, "Rasmus Schultz" <rasmus <at> mindplay.dk> wrote: > From the comments in the documentation, it seems others are having the same > problem with version_compare() that I was running into: > > http://us2.php.net/version_compare > > Look at all those code-samples and "extensions" to the function - I found > it very odd that the documentation does not explain how an "empty" > version-number is interpreted compared to the strings and numbers, which > are clearly defined and explained. > > For example, I was not the only one who found it odd that "1.0" is > considered less than "1.0.0" - wouldn't it make sense to "pad" the shortest > version-number with zeroes? e.g. "1.0" if compared against "1.0.0" would be > padded with zeroes at the end, e.g. as "1.0.0". > > Of course that would break backwards compatibility, which kind of defeats > the purpose of having a standardized version-number comparison standard. > But as you can see, people aren't using the function as-is anyway - they're > writing their own... > > - Rasmus Schultz >
bottom line, I think, is that version_compare() should work for the
version-numbering scheme used by PHP, so that it works for checking the PHP
version-number. if you happen to use the same version-numbering scheme for
your PHP projects, good for you - if you don't, too bad... there are just
too many version-numbering schemes to support them all...
On Sat, Jul 21, 2012 at 2:22 AM, Kris Craig <kris.craig <at> gmail.com> wrote:
>
> > 1.01 eq 1.1
>
> Could you explain this one to me? In every versioning system I've ever
> used, 1.1 would be greater than 1.01, not equal.
>
> > On Fri, Jul 20, 2012 at 5:07 PM, Stas Malyshev <smalyshev <at> sugarcrm.com
RSS Feed