Bug #52551 [Com]: range() warns if step exceeds the distance between the min and max values
[email protected] ("info at ava dot codes")
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=52551&edit=1
ID: 52551
Comment by: info at ava dot codes
Reported by: planet36 at gmail dot com
Summary: range() warns if step exceeds the distance between
the min and max values
Status: Closed
Type: Bug
Package: Documentation problem
Operating System: Linux
PHP Version: trunk-SVN-2010-08-06 (snap)
Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
range() warns if a step exceeds the distance between the min and max values if you are putting that kind of web development. Should just make that coding more properly - https://ava.codes/hire/angular-developer
Previous Comments:
------------------------------------------------------------------------
[2013-10-05 07:49:37] [email protected]
There is no convention or necessity to document every warning or error that a function may produce.
I don't see a reason for this bug to remain open.
------------------------------------------------------------------------
[2010-08-06 08:24:21] planet36 at gmail dot com
uname --all
Linux ubuntu 2.6.32-24-generic-pae #38-Ubuntu SMP Mon Jul 5 10:54:21 UTC 2010 i686 GNU/Linux
./php --version
PHP 5.3.99-dev (cli) (built: Aug 6 2010 01:43:07)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies
------------------------------------------------------------------------
[2010-08-06 08:22:32] planet36 at gmail dot com
Description:
------------
The range() function incorrectly warns when the step size exceeds the distance between the min and the max values. But when the min and max values are equal, there is no warning. This is related to #21060 and #46631.
The documentation at <http://www.php.net/manual/en/function.range.php> gives no mention of possible warnings or errors.
The 'seq' utility is a good guide as to the expected output of the test script.
$ seq 1 2 4
1
3
$ seq 1 2 3
1
3
$ seq 1 2 2
1
$ seq 1 2 1
1
Test script:
---------------
print "range(1, 4, 2)\n";
print_r(range(1, 4, 2));
print "\n";
print "range(1, 3, 2)\n";
print_r(range(1, 3, 2));
print "\n";
print "range(1, 2, 2)\n";
print_r(range(1, 2, 2));
print "\n";
print "range(1, 1, 2)\n";
print_r(range(1, 1, 2));
print "\n";
Expected result:
----------------
range(1, 4, 2)
Array
(
[0] => 1
[1] => 3
)
range(1, 3, 2)
Array
(
[0] => 1
[1] => 3
)
range(1, 2, 2)
Array
(
[0] => 1
)
range(1, 1, 2)
Array
(
[0] => 1
)
Actual result:
--------------
range(1, 4, 2)
Array
(
[0] => 1
[1] => 3
)
range(1, 3, 2)
Array
(
[0] => 1
[1] => 3
)
range(1, 2, 2)
Warning: range(): step exceeds the specified range in /home/stevew/Desktop/PHP/php-trunk-201008060430/sapi/cli/test-range.php on line 16
range(1, 1, 2)
Array
(
[0] => 1
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=52551&edit=1