Bug #66238 [Opn->Nab]: Unexpected behavior in for loop
| From: | bwoebi@php.net | Date: | Thu, 05 Dec 2013 16:37:00 +0000 |
| Subject: | Bug #66238 [Opn->Nab]: Unexpected behavior in for loop | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183139@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66238&edit=1
ID: 66238
Updated by: bwoebi@php.net
Reported by: gnjagi at gmail dot com
Summary: Unexpected behavior in for loop
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
010 is an octal notation, so parsed as 8.
025 in octal is 21.
033 in octal is 27.
See also http://www.php.net/manual/en/language.types.integer.php
for the different integer notations.
Previous Comments:
------------------------------------------------------------------------
[2013-12-05 13:30:25] gnjagi at gmail dot com
Unexpected behavior in a for loop when a value is zero padded
------------------------------------------------------------------------
[2013-12-05 12:27:43] gnjagii at gmail dot com
for($i=010;$i<20;$i++){
echo $i."<br/>";
}
expected is a loop with 10- 19
for($i=025;$i<50;$i++){
echo $i."<br/>";
}
expected is a loop with 25- 49
for($i=025;$i<50;$i++){
echo $i."<br/>";
}
expected is a loop with 33- 59
the actual result as you see in the link is something else
------------------------------------------------------------------------
[2013-12-05 12:17:44] phpmpan at mpan dot pl
Please stick to bug report template. What is the expected result?
As far as I can see (until I miss something) the linked (why linked instead of just providing the
result?) output is exactly what is expected. There are three loops. First output values from 8 to
19, the second outputs values from 21 to 49 and the third: from 27 to 59. This is exactly what the
code states and how it should work.
------------------------------------------------------------------------
[2013-12-05 10:15:53] gnjagi at gmail dot com
Description:
------------
For loop with $i zero padded gives unexpected behaviour
Test script:
---------------
for($i=010;$i<20;$i++){
echo $i."<br/>";
}
echo "<br/>";
for($i=025;$i<50;$i++){
echo $i."<br/>";
}
echo "<br/>";
for($i=033;$i<60;$i++){
echo $i."<br/>";
}
Expected result:
----------------
The $i value is not what is stated in the for loop
Actual result:
--------------
http://softlogic.me.ke/numconv.php
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66238&edit=1