# version_compare(): 1 != 1.0 != 1.0.0

- Thread: https://externals.io/message/4762
- Original archive: https://news-web.php.net/php.internals/4762
- Started by Tomas V.V.Cox on 2003-10-08T13:23:03+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #4762 — Tomas V.V.Cox — 2003-10-08T13:23:03+00:00

URL: https://externals.io/message/4762#4762

What's the logic behind `version_compare()` thinking that 1 < 1.0 < 1.0.0? 
Talking about the versionning world, to me look quiet obvious that all 
these should be equivalent. If PHP 5.0 is released the next release 
won't be 5.0.0, will be 5.0.1 intead.

That could lead in problems with software dependecies, because I'd need 
to know the amount of "digits" the next version will have for setting 
the exact dependency on it. This is, I can't set a dep in PHP6 to 
greater or equal than 6.0.0 because probably it would be 6.0 or even 
just 6. I'd need to set the dep to "6" if want to cover all the cases 
and doesn't look very clear for a normal user.

Test cases:

$ php -r "var_dump(version_compare('1', '1.0'));"
int(-1)
$ php -r "var_dump(version_compare('1.0', '1.0.0'));"
int(-1)


Tomas V.V.Cox
