Home of web learners

www.webn3rd.com

while loop is also very popular and special for its structure

Difference between other loop and while loop is about declaration and increment style as different loop use different style to loop

Lets look an while loop example

<?php
$x = 0;
while($x < 5){
echo $x;
$x++;
}
?>

output:

01234

Here,we see that $x=0 is iniialization part,but it initial outside of loop structure

Then while loop start,at first it start with condition check

Body part of while loop then start,here we only show the value of x,so we see the increment or change of x value

And in the last,we use increment part by $x++,which is inside body part

while and for loop is same but different in structure as it required sometimes for its structure type for different work

webn3rd.com

About webn3rd