Php program to print the number using while loop

A Php program to print the number using while loop. In this program we can print the number by using looping statement. PHP will execute the nested statement twice as long as the while expression evaluates to true. If the while expression evaluates to false from the start, the nested statement will not be executed.

<?php 
$x = 95;

while($x <= 100)
{
echo "$x <br>";
$x++;
}
?>

 

Output:

95
96
97
98
99
100

What is while loop in php language

They are used to repeatedly execute a block of code until the set condition is met. When should you use while loops. While loops are used to execute a section of code until a specific condition is met. A while loop can be used to read records returned by a database query.

What is increment operator in php

The ++ and — increment and decrement operators, which are used in C, are also defined in PHP. The increment operator, as its name suggests, increases the value of the operand variable by one. The Decrement operator subtracts one from the value. Both are unary operators, which means they only require one operand.

Difference between in i++ and ++i in php language

++ is the difference. I will update the value of the I variable and return it, whereas $i++ will return the original value, so increment it. The term “post-increment” refers to the use of $i++. After assigning the original value of I to $j, it increments the value of $i. Pre-increment is the symbol I