#21182 [Com]: range() change value of string argument
| From: | derdik at ukr dot net | Date: | Wed, 25 Dec 2002 16:43:55 +0000 |
| Subject: | #21182 [Com]: range() change value of string argument | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-28360@lists.php.net to get a copy of this message | ||
ID: 21182
Comment by: derdik@ukr.net
Reported By: lofa@forma.kharkov.ua
Status: Open
Bug Type: Arrays related
Operating System: FreeBSD
PHP Version: 4.2.1
New Comment:
I searched range's source (php4/ext/standard/array.c)
It seems that problem is in string
for (; *low <= *high; (*low) += (unsigned int)lstep) {
add_next_index_stringl(return_value, low, 1, 1);
}
+= increments not pointer, but value, to which low points.
Therefore for(;;) iterates values between first characters of high and
low strings.
Previous Comments:
------------------------------------------------------------------------
[2002-12-25 10:02:09] lofa@forma.kharkov.ua
I have the following code:
<?PHP
$a = "20";
$b = "30";
$result = range($a, $b);
echo $a;
?>
For some reason it display "40".
I know that I have to write
$result = range((int)$a, (int)$b);
But why range() change value of argument?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21182&edit=1