Edit report at http://bugs.php.net/bug.php?id=52551&edit=1
ID: 52551 User updated by: planet36 at gmail dot com Reported by: planet36 at gmail dot com Summary: range() warns if step exceeds the distance between the min and max values Status: Open Type: Bug Package: *General Issues Operating System: Linux PHP Version: trunk-SVN-2010-08-06 (snap) Block user comment: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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 http://bugs.php.net/bug.php?id=52551&edit=1