Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda and colon in while statement for PHP?

Tags:

php

What does the below code mean (it's a lambda in the while-statement, then a colon after)? Coming from JavaScript, I have no idea what that means or even how to search for that. Can anyone help explain this?

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

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

like image 604
TruMan1 Avatar asked Feb 10 '13 06:02

TruMan1


1 Answers

This is a less-common while structure:

while (condition):
    doSomething();
endwhile;

This is not how things are traditionally done, but it is valid syntax. See while loop syntax for more details, as well as alternative control syntax.

like image 115
Levi Morrison Avatar answered Sep 19 '22 21:09

Levi Morrison