From:             
Operating system: Linux
PHP version:      trunk-SVN-2010-08-06 (snap)
Package:          *General Issues
Bug Type:         Bug
Bug description:range() warns if step exceeds the distance between the min and 
max values

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 bug report at http://bugs.php.net/bug.php?id=52551&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52551&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52551&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52551&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52551&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52551&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52551&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52551&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52551&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52551&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52551&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52551&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52551&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52551&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52551&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52551&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52551&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52551&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52551&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52551&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52551&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52551&r=mysqlcfg

Reply via email to