|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-02-27 23:52 UTC] 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) } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 11:00:02 2025 UTC |
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.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')