endforeach in loops?

前端 未结 7 1477
爱一瞬间的悲伤
爱一瞬间的悲伤 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:

    <?php foreach ($foo as $bar) : ?>
        <div ...>
            ...
        </div>
    <?php endforeach; ?>
    
    0 讨论(0)
提交回复
热议问题