Loop : In normal language that means repeat some steps. In your program when you want to execute same statement so many times at that time you have to use this task. In PHP, we have the following looping statements: while - loops through a block of code while a specified condition is true do...while - loops through a block of code once, and then repeats the loop as long as a specified condition is true for - loops through a block of code a specified number of times foreach - loops through a block of code for each element in an array The while loop : The syntax of while loop is : While (your condition) { your code to be executed; } Lets understand while loop with example : $i=0; while($i<5) { echo "Php while loop"; $i++; } The output of the above program is : Php while loop Php while loop Php while loop Php while loop Php while loop Keep in mind when the condition becomes false the loop will terminate. Because i...
Comments
Post a Comment