note 114493 added to function.range

From: Date: Wed, 26 Feb 2014 22:22:52 +0000
Subject: note 114493 added to function.range
Groups: php.notes 
Request: Send a blank email to php-notes+get-198735@lists.php.net to get a copy of this message
So with the introduction of single-character ranges to the range() function, the internal function tries to be "smart", and (I am inferring from behavior here) apparently checks the type of the incoming values. If one is numeric, including numeric string, then the other is treated as numeric; if it is a non-numeric string, it is treated as zero. But. If you pass in a numeric string in such a way that is is forced to be recognized as type string and not type numeric, range() will function quite differently. Compare: <?php echo implode("",range(9,"Q")); // prints 9876543210 echo implode("",range("9 ","Q")); //space after the 9 // prints 9:;<=>?@ABCDEFGHIJKLMNOPQ echo implode("",range("q","9 ")); // prints qponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:987654 ?> I wouldn't call this a bug, because IMO it is even more useful than the stock usage of the function. ---- Server IP: 64.71.164.2 Probable Submitter: 66.171.190.11 ---- Manual Page -- http://php.net/manual/en/function.range.php Edit -- https://master.php.net/note/edit/114493 Del: integrated -- https://master.php.net/note/delete/114493/integrated Del: useless -- https://master.php.net/note/delete/114493/useless Del: bad code -- https://master.php.net/note/delete/114493/bad+code Del: spam -- https://master.php.net/note/delete/114493/spam Del: non-english -- https://master.php.net/note/delete/114493/non-english Del: in docs -- https://master.php.net/note/delete/114493/in+docs Del: other reasons-- https://master.php.net/note/delete/114493 Reject -- https://master.php.net/note/reject/114493 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198735) next »