Like any other language, loop in PHP is used to execute a statement or a block of statements, multiple times until and unless a specific condition is met. This helps the user to save both time and effort of writing the same code multiple times.
PHP supports four types of looping techniques;
for loop
while loop
do-while loop
foreach loop
Let us now learn about each of the above mentioned loops in details:
for loop: This type of loops is used when the user knows in advance, how many times the block needs to execute. That is, the number of iterations is known beforehand. These type of loops are also known as entry-controlled loops. There are three main parameters to the code, namely the initialization, the test condition and the counter.
for (initialization expression; test condition; update expression) {
// code to be executed
}
#PHPTutorial #PHPForBeginners #AtifNaseem
Download
0 formats
No download links available.
For Loop in PHP - Become a PHP Master - 07 | NatokHD