Skip to main content

Posts

Showing posts with the label forloop

LOOPS

for loop: for($start=0; $start < 11; $start++) { echo "for loop test";//text will be printed 11 times } while loop: while (condition) { //statement } do while loop: do statement while (condition) The difference is that your statement gets executed at least once. In a normal while loop, the condition could be met before your statement gets executed.

CONTINUE & BREAK

continue and break statements in php are very importants these are very usefull in loops if you want to skip at any point in loop and you want that after this condition below code should not be executed then use continue example: for($i=0;$i<10;$i++){ if($i==6) break;// loop will be terminated and after 6 it will be outside from loop scope echo "before continue"; continue; echo "after continue";//this will never be executed }