While Control Structure:
While is the simplest form of loop. While loop checks the condition first and if it returns true then it proceeds and allows to execute the codes written within the block and keep executing the codes until the condition becomes false, sometimes it fails to meet the condition to stop, and become infinite loop. While loop is also known as pre-test loop.
Basic format of while loop is as follows:
We can have nested while loop, we can use the alternative structure in while like we have done in if control structure as given in the following example:
echo "Value of \$i is $i <br/>";
Value of $i is 1
Value of $i is 2
Value of $i is 3
Value of $i is 4
Value of $i is 5
Value of $i is 6
Value of $i is 7
Value of $i is 8
Value of $i is 9
Value of $i is 10
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.