Definition
The while loop checks the condition. If the condition is true then, the loop inside the curly braces executes. The condition is always true in an infinite loop. After that, the loop will terminate the code manually or through manual interruption to stop the program.
Syntax:
while (condition) {
// Code to be executed
}
Example:
<?php
while (1) { // condition is always true
echo "This is an infinite while loop<br>";
}
?>
Output:
It is an infinite while loop It is an infinite while loop It is an endless while loop ... (continues endlessly)
