Edit report at http://bugs.php.net/bug.php?id=52650&edit=1
ID: 52650 Updated by: [email protected] Reported by: eagler67 at yahoo dot com Summary: Different result when using a number than a variable. -Status: Open +Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: Xp sp3 PHP Version: 5.3.3 Block user comment: N New Comment: $index is being set to the result of ($a == $b), which is the boolean value TRUE, rather than an integer. Incrementing a boolean TRUE results in it remaining TRUE, so the value of $index never changes. Beyond that, "TRUE <= 10" (which is what your loop condition effectively boils down to) will always be true, therefore the loop never ends. Not a bug, closing. Previous Comments: ------------------------------------------------------------------------ [2010-08-20 06:54:54] eagler67 at yahoo dot com Description: ------------ When i put a direct number or variable in a for block, it works fine, but if i do an equation it fails. Even if it is very simple. Test script: --------------- <?php error_reporting(0); $index = "0"; $a = "0"; $b = "0"; //As you can see variable returns 1. echo ">" . ($a==$b) . "<" . "<br>"; // So... this should go from 1 to 10. // replace "($a==$b)" with 1 and everything works as it should. for ($index=($a==$b); $index<=10; $index++) { // this always prints 1. An endless loop. echo $index . "<br>"; } ?> Expected result: ---------------- >1< 1 2 3 4 5 6 7 8 9 10 Actual result: -------------- >1< 1 1 1 1 1 1 1 1 1 1 1 1 (infinite) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52650&edit=1
