What is Loop in Php

What is Loop?

Loops are control structures that are used to repeat a given section of a code a certain number of times or till the particular condition is met. Loops in Php are mainly used to execute the same block of code a specific number of times. 

Types of Loops

  • For Loop 
  • For Each Loop
  • While Loop
  •  Do while Loop
For Loop : For loop is  used to iterate through a sequence or an array of data types or objects. The executions hinge upon a boolean condition(true or false). If the condition is true then the loop continues to execute but if the condition is false then the loop will break.

Syntax of For Loop
For Each Loop : For each loop as the name suggest that this loop is used to iterate through items of array/collections. Its main function is to iterate through each element of an array. 



While Loop : The while loop is  used in executing a block of code if and till the condition expression is true. If the condition expression is true then the code block will executed. After the code has executed the condition expression will be again evaluated and the loop will continue until the condition expression is found to be false.




Do While Loop: The do while will execute a condition once and it will repeat the loop as long as the condition will be true.

For any kind of training query regarding Php contact us at: 9911343087 and for further details visit our website: http://thecoderclinic.com/

Comments

Popular posts from this blog

Importance of OOPs in PHP.

A Glance At Php

Importance Of MVC In Php.