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

javascript - ScrollTo Effect (href to div) -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -