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 a while-loop condition not end with a semicolon in PHP? | ComputerScienceOne | Bifalgorithm | Bifalgorithm