Lambda and colon in while statement for PHP?

What does the lower code mean (this is the lambda in the while-statement, then the colon after)? Based on JavaScript, I have no idea what this means or even how to look for it. Can someone explain this?

while ($query->have_posts()): $query->the_post();

Btw I got this from WordPress, but is the syntax pure PHP?

+5
source share
3 answers

This is a less common structure:

while (condition):
    doSomething();
endwhile;

This is not how traditionally done, but it is the syntax. See while while loop syntax as well as alternative control syntax .

+7
source

This is an alternative syntax for control structures.

+1
source

, :

while (expression) :
  //actions
endwhile;

:

while (expression) {
  //actions
}

, , . $query->havePosts() while, while.

+1

All Articles