php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41119 range() function behavior different on PHP6 and PHP5
Submitted: 2007-04-17 13:48 UTC Modified: 2008-01-14 10:41 UTC
From: mahesh dot vemula at in dot ibm dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 6CVS-2007-04-17 (snap) OS: RHEL 4
Private report: No CVE-ID: None
 [2007-04-17 13:48 UTC] mahesh dot vemula at in dot ibm dot com
Description:
------------
Output of PHP5 and PHP6 differ for range() function. The difference appears when an empty string("") is given as low value and FLOAT as high value. PHP5 gives the consistent output for an empty string and normal string, which is an "array of float elements".

Whereas PHP6 treats empty and normal strings differently when high value is a FLOAT. The output of range() with an empty string("") as low value is "array of Integer elements" and with regular string as low value is "array of float elements".

Environment:
Operating System: RHEL 4
Linux Kernel : Linux 2.6.9
PHP Version: PHP 5.2 (Built on Apr 17, 2007 from snaps.php.net)
PHP Configure Setup: ./configure


Reproduce code:
---------------
<?php
var_dump( range("", 2.2) );
var_dump( range("string", 2.2) );
?>


Expected result:
----------------
array(3) {
  [0]=>
  float(0)
  [1]=>
  float(1)
  [2]=>
  float(2)
}
array(3) {
  [0]=>
  float(0)
  [1]=>
  float(1)
  [2]=>
  float(2)
}


Actual result:
--------------
PHP5 gives the output as expected but PHP6 gives the following output:

array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
array(3) {
  [0]=>
  float(0)
  [1]=>
  float(1)
  [2]=>
  float(2)
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-14 10:41 UTC] felipe@php.net
Works fine on PHP 6.0.0-dev (cli) (built: Jan 14 2008 08:38:52)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC