Loops in PHP are used to execute the same block of code a specified number of times. This is called the body of the loop. Every loop depends on the condition. It keeps executing the block of code unless the condition is met true or stands false (depends on the loop’s type that we will discuss in a moment).
There is a terminating point for each loop that ends the loop when the condition is satisfied. Like in our earlier discussed example if we want to display a hundred lines of ten equal signs each then we have the following attributes that will make up our loop in theory;
Condition:
Body of the loop:
Terminating Point:
Loop Run:
Remember, I am using these terms from my own dictionary because I will use them to explain things otherwise these terms or not standard and attached with loops definitions you can use whatever theory you want to explain these terms in your own words.
PHP supports the following four loop types.
for loop :
while loop :
do...while loop:
foreach loop :
We will discuss about continue and break keywords used to control the loop's execution.
© 2025 Easy To Learning. All Rights Reserved | Design by Easy To Learning