????? ????? ????
on 2012-04-17 15:29:36
This is a very informative article. I was looking for these things and here I found it. I am doing a project and this information is very useful me. Some things in here I have not thought about before
on 2010-05-30 01:30:40
@Scott Baker: Thank you for finding this. I fixed this and went ahead and fixed a few other bugs I found in this function (you can never be too nit picky), including:
- An empty string is acceptable as a version number. (Currently throws an error.) An empty string should always be less-than a non-empty string (PHP behavior).
- Both the operators and the version words were being treated as case-insensitive when PHP treats them as case-sensitive.
- An invalid operator should make the function return null instead of using the "<" operator as a fallback.
The code has also been reduced by many lines and documented better. You can get the updated code here http://github.com/kvz/phpjs/raw/master/functions/info/version_compare.js before it is updated on the main website.
Scott Baker
on 2010-05-28 23:51:20
This may be nit picky, but I've seen version numbers with leading zeros as filler. This breaks this compare.
Correct:
version_compare('4.1.0.52','4.1.0.52') = 0
Not Correct:
version_compare('4.1.0.52','4.01.0.51') = 0
version_compare('4.1.0.52','4.01.0.51','>') = false