Concept
Why should a while-loop condition not end with a semicolon in PHP?
ComputerScienceOne / While Loops
"The continuation condition does not contain a semicolon since it is not an executable statement. Just as with an if-statement, if we had placed a semicolon it would have led to unintended results. Consider the following:\n\n1 while($i <= 10); {\n\n2 //perform some action\n\n3 $i++; //iteration\n\n4 }\n\nA similar problem occurs. The while keyword and continuation condition bind to the next executable statement or code block. As a consequence of the semicolon, the executable statement that gets bound to the while loop is empty."
Related Ideas
- Why should you avoid a semicolon after a while condition?ComputerScienceOne · While Loops
- Why should you avoid a semicolon after a while-loop condition?ComputerScienceOne · While Loops
- How does a do-while loop differ from a while loop in PHP?ComputerScienceOne · Do-While Loops
- How does a do-while loop differ from a while loop in PHP?ComputerScienceOne · Foreach Loops
- How does a do-while loop differ from a while loop in C?ComputerScienceOne · Do-While Loops