Posts

Showing posts with the label Looping Statement In PHP

Looping Statement In PHP - While Loop, Do While Loop, For Loop, Foreach Loop and Break and Continue Statement

Image
  What is Looping Statement In PHP ? Loops execute a block of code a specified number of times, or while a specified condition is true. Type of Loops in PHP The while Loop The Do …while Loop The For Loop The Foreach Loop Break and Continue Statement The While Loop While structure is the another type of loop statement, where the condition is checked at first, the iteration will not stop even if the value changes while executing Statements. Syntax-   while ( condition ) { code to be executed } Example-    <?php $i = 0 ; while ( $i <= 10 ) { //output value 0 from 10 echo "The Number is " . $i . "<br>" ; $i ++ ; } ?> Output- The Number is 0 The Number is 1 The Number is 2 The Number is 3 The Number is 4 The Number is 5 The Number is 6 The Number is 7 The Number is 8 The Number is 9 The Number is 10 The Do While Loop Do while statement is same as the while statement, the only difference is that it evaluates the expression at the end. Syntax –  ...