endforeach in loops?

前端 未结 7 1475
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 05:59

I use brackets when using foreach loops. What is endforeach for?

7条回答
  •  有刺的猬
    2020-12-01 06:52

    It's the end statement for the alternative syntax:

    foreach ($foo as $bar) :
        ...
    endforeach;
    

    Useful to make code more readable if you're breaking out of PHP:

    
        
    ...

提交回复
热议问题