php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15003 problem with range() function
Submitted: 2002-01-11 18:03 UTC Modified: 2002-01-11 18:37 UTC
From: jolt at mail dot contactdesigns dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.1.1 OS: Linux 2.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jolt at mail dot contactdesigns dot com
New email:
PHP Version: OS:

 

 [2002-01-11 18:03 UTC] jolt at mail dot contactdesigns dot com
problem with range() function:

$test = range(settype($seats[1], 'integer'), settype($seats[2], 'integer'));

First argument equals 1 second equals 25 confirmed by this var_dump:

[1]=> int(1) [2]=> int(25) 

var_dump($test) returns:

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


PHP configure setup:

./configure --with-mysql=/usr/local/mysql --with-zlib --with-apache=../$apache --enable-track-vars --with-config-file=$target/conf


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-11 18:09 UTC] rasmus@php.net
Not a bug.

settype() returns true/false.  In your case it returned true in both cases so your range was actually range(1,1) which doesn't make much sense.  If you want to cast arguments use (int)$var inside that call.
 [2002-01-11 18:37 UTC] jolt at mail dot contactdesigns dot com
I should have read the settype() docs more closely, however, I only added the settype after upgrading to 4.1.1 broke my older code written in 4.0.6 that was using range().  I believe this may have been caused by the addition of support for characters in addition to numbers in 4.1.0 for range().  The numbers were output from preg_match() in the form of back references (third optional paramter to preg_match()) and were strings although they would have passed is_numeric().  Therefore, they ran in older versions of range() just fine.  I should have tested more before submitting a bug report that was a false alarm.  Sorry :-(

  
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 14:01:35 2024 UTC