php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72795 Function version_compare
Submitted: 2016-08-09 12:09 UTC Modified: 2016-08-09 16:21 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dink10 at rambler dot ru Assigned: cmb (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dink10 at rambler dot ru
New email:
PHP Version: OS:

 

 [2016-08-09 12:09 UTC] dink10 at rambler dot ru
Description:
------------
Function version compare works incorrectly. 

Example 

echo version_compare( "10.1.0", "10.1", "<=" );

Output: false

It wotrks only in next case:

echo version_compare( (float)"10.1.0", (float)"10.1", "<=" );

I suppose it is bug


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-09 16:21 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: *General Issues +Package: Unknown/Other Function -Assigned To: +Assigned To: cmb
 [2016-08-09 16:21 UTC] cmb@php.net
This is not a bug. Consider, for instance, the following:

  'abc' <= 'ab' // => false

version_compare() works the same (of course, not single characters,
but instead groups delimited by separators are compared).

BTW:

  echo version_compare( (float)"10.1.0", (float)"10.1", "<=" );

is identical to

  echo version_compare(10.1, 10.1, '<=');
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 13:01:34 2025 UTC