php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21060 range() gives warning and returns false when low == high
Submitted: 2002-12-17 01:13 UTC Modified: 2002-12-19 19:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cnb at freedomink dot org Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4CVS-2002-12-16 (dev) OS: Linux 2.4.18
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: cnb at freedomink dot org
New email:
PHP Version: OS:

 

 [2002-12-17 01:13 UTC] cnb at freedomink dot org
<?php

range(2,2);

?>

Warning: range() [http://www.php.net/function.range]: 
step exceeds the specified range in - on line 3

Numerous scripts expect range() to return the low 
(or high) value (in this case 2 ) when low == high. 

This is useful in cases where the low and high values
are dynamically generated.

But since the default step is 1, there is a warning
and a FALSE returned when low == high.

http://freedomink.org/code/php/patches/array.c.patch

The above patch makes range return low when 
(low == high).

Please comment.

- Chandrashekhar

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-19 19:00 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Nothing wrong with this behaviour, the low & high point are the same, hence the false output indicating failure.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 10:01:38 2025 UTC