Lambda and colon in while statement for PHP?

后端 未结 3 1550
北海茫月
北海茫月 2021-01-12 14:04

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 t

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-12 14:35

    In general, this:

    while (expression) :
      //actions
    endwhile;
    

    is the same as this:

    while (expression) {
      //actions
    }
    

    which is what you're probably used to. The bracketted expression $query->havePosts() is just the condition of the while, and the sentence after the colon is the first line within the while.

提交回复
热议问题