PHP for loop : equal or smaller than - works, equal to - creates infinte loop -


this code works

<?php      ($x = 0; $x <= 10; $x++) {         echo "the number is: $x <br>";     }  ?>  

but if instead of " <= " use " = " php gets infinite loop timesout

<?php          ($x = 0; $x = 10; $x++) {             echo "the number is: $x <br>";         }  ?> 

is expected behavior?

yes, you're using assignment operator instead of comparison operator. there's no way loop end.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -