Because in your for
loop, continue
is the last statement so, nothing is available to skip, as it will automatically go to beginning of the next iteration.
CONTINUE
continue is used within looping structures to skip the rest of the
current loop iteration and continue execution at the condition
evaluation and then the beginning of the next iteration
BREAK
break ends execution of the current for, foreach, while, do-while or
switch structure.
for($a=1; $a<=10; $a++){<--------------------┐
|
echo $a; |
echo "<br>"; |
if($a==6){ |
break; ----- jumps here ------┐ |
} | |
| |
Remove else `continue` here,it will go | |
to the beginning automatically until | |
loop fails -----------------------------------┘
|
} |
<--------------------┘
AS PER COMMENT:
<?php
for($a=1; $a<=10; $a++){
echo $a;
echo "<br>";
if($a==6){
break;
}
else{
echo "before continue <br/>";
continue;
echo "after continue <br/>"; // this will not execute because continue goes beginning of the next iteration
}
}