Bug #66238 [Opn]: Unexpected behavior in for loop

From: Date: Thu, 05 Dec 2013 13:30:25 +0000
Subject: Bug #66238 [Opn]: Unexpected behavior in for loop
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183132@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 User updated by: gnjagi at gmail dot com Reported by: gnjagi at gmail dot com -Summary: Expected behavior in for loop +Summary: Unexpected behavior in for loop Status: Open Type: Bug Package: *General Issues PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Unexpected behavior in a for loop when a value is zero padded Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#183132) next »