Re: common issue with version_compare()

From: Date: Fri, 20 Jul 2012 22:38:08 +0000
Subject: Re: common issue with version_compare()
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-61588@lists.php.net to get a copy of this message
On 21/07/2012, at 10:22 AM, Hartmut Holzgraefe wrote: > On 07/20/2012 11:07 PM, Stas Malyshev wrote: >> 1.0.0 and 1.0 are different things. If you want to make a comparison >> that takes into account only two components, you can just cut them both >> to two components, then compare. > > it is hart to imagine a 1.0 followed by 1.0.0 in real world, but > the only reason for something like this that i can come up with > is that, for whatever reason, a project wants to change from > two component version numbers to three component ones right after > having done a 1.0. And in that case a 1.0.0 following the 1.0 > would be a new release, even if it only differs by the extra .0 > > And so 1.0 < 1.0.0 would be perfectly correct. > > -- > hartmut I've had to use two digit version numbers when upgrading frameworks during the 5.4 development phrase. This meant that version_compare('5.4', PHP_VERSION); would return -1 for things like 5.4.0-beta1. Padding the 5.4 to 5.4.0 would've broken the comparison, as well as changing the return value of version_compare('5.4', PHP_VERSION); when running 5.4.0. --- Simon Welsh Admin of http://simon.geek.nz/

« previous php.internals (#61588) next »