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
Post a Comment