Php program to print the multiple numbers using for loop

A Php program to print the multiple numbers using for loop. In this program we can print the multiple numbers in the output using for loop. A “For” Loop is a programming construct that repeats a block of code for a specified number of times. For example, if we want to check every student’s grade in the class, we can loop from 1 to that number.

<?php 
for ($x = 1; $x <= 5; $x++)
{
echo "$x <br>";
}
?>

 

Output:

1
2
3
4
5

What is For loop in php

A “For” Loop is used to repeat a block of code for a predetermined number of times. If we want to check every student’s grade in the class, for example, we loop from 1 to that number. A loop is used to repeatedly execute a set of statements until a certain condition is met. When showing numbers from 1 to 100, for example, you might wish to set the value of a variable to 1 and display it 100 times, raising its value by 1 with each loop iteration.

What is Increment operator in php

PHP offers a built-in method for incrementing a number or a string by appending ++ to the end of the variable. After utilising a variable in an expression, the post increment operator is used to increase its value. The value is used inside the expression and then incremented by one in the post increment.