while loop in PHP
Table of Content:
The for loop repeats a segment of code a specific number of times, while the while loop repeats a segment of code an unknown number of times. The while loop works differently than the for loop.
Syntax:
while(condition){ // execute this code; // your code here }
Example of while
loop
"; } ?>
Output:
The above code will produce the following result-
5 10 15 20 25
In the above code, a variable named num is initialized with the value of 0. The condition in the while loop is that while num is less than 25, 5 should be added to num. Once the value of num is greater than 25, the loop will stop executing.