Why php for loop can be run without counter?

Viewed 62
for( ; ; )
{echo 'hello';}

I'm a fresher PHP, hopefully someone can explain to this kind of question for me.Thanks.

1 Answers

From the PHP manual:

"Each of the expressions can be empty or contain multiple expressions separated by commas. ... expr2 being empty means the loop should be run indefinitely (PHP implicitly considers it as TRUE, like C)."

There is a list of examples and /* example 3 */ is an example of an "empty" for loop.

Read more/all on https://secure.php.net/manual/en/control-structures.for.php

Related