Loop

$x=1;
do{
 echo $x;
 $x++;
}while($x<=10);
//At first code will be executed in do{} and then will be continuing checking condition if condition true then will go inside in do{} to execute code otherwise not.
An important thing about do{}while() is At the very first execution is not depend on condition but from the second execution depend on condition.


$x=1;
while($x<=10){
 echo $x;
 $x++;
}
//At the beginning check the condition if condition is true then execute otherwise not. The characteristic of this loop is this loop run clock wise.


for($i=1; $i<=10; $i++){
 echo $i;
}
// This loop run anti-clock wise first initiate value, then check condition if condition is true then go to execution, after completing the execution go to the third parameter to increment initialized value.

continue;
//Use to skip a single execution in loop

break;
//Use to get out from a loop;

Comments

Popular posts from this blog

Deploy laravel application to digital ocean droplet

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine