Bug #66793 [Com]: range(0,9) and range('0','9') both produce intergers in array
| From: | a dot r dot austin at gmail dot com | Date: | Fri, 28 Feb 2014 21:10:40 +0000 |
| Subject: | Bug #66793 [Com]: range(0,9) and range('0','9') both produce intergers in array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184478@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66793&edit=1
ID: 66793
Comment by: a dot r dot austin at gmail dot com
Reported by: araustin at gmail dot com
Summary: range(0,9) and range('0','9') both produce intergers
in array
Status: Not a bug
Type: Bug
Package: Output Control
Operating System: Win 8
PHP Version: 5.4.25
Block user comment: N
Private report: N
New Comment:
You say that what about range('24','42') ??? Well, it is the same as to ask what
about range('pk','rt')... It does not make sense. If is it a string, it should
be an ascii character, one char long.
range('24','42') should be error of some sorts just like
range('pk','rt')
Previous Comments:
------------------------------------------------------------------------
[2014-02-28 10:33:43] ab@php.net
That may sound logic for your particular example, however if you spread it with say
range('24','42'), it'll become inconsistent. Concatenation with integer
still works, and the way it's handled now is consistent - numeric strings become numbers, it
was introduced somewhere in PHP-4 according to the doc page. And btw that is platform independent
behavior.
------------------------------------------------------------------------
[2014-02-27 23:52:14] araustin at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.range
---
Test script:
---------------
$allowedChars_num = range(0,9);
$allowedChars_str = range('0','9');
var_dump($allowedChars_num);
var_dump($allowedChars_str);
Expected result:
----------------
range(0,9) is proper, making an array of integers
range('0','9') should be making an array of strings, ex:
'0','1','2' etc...
Actual result:
--------------
array(10) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) [5]=>
int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) }
array(10) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) [5]=>
int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66793&edit=1