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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC