Difference between break and continue in PHP?

后端 未结 10 2536
粉色の甜心
粉色の甜心 2020-12-02 05:02

What is the difference between break and continue in PHP?

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 05:45

    I am not writing anything same here. Just a changelog note from PHP manual.


    Changelog for continue

    Version Description
    
    7.0.0 - continue outside of a loop or switch control structure is now detected at compile-time instead of run-time as before, and triggers an E_COMPILE_ERROR.
    
    5.4.0   continue 0; is no longer valid. In previous versions it was interpreted the same as continue 1;.
    
    5.4.0   Removed the ability to pass in variables (e.g., $num = 2; continue $num;) as the numerical argument.
    

    Changelog for break

    Version Description
    
    7.0.0   break outside of a loop or switch control structure is now detected at compile-time instead of run-time as before, and triggers an E_COMPILE_ERROR.
    
    5.4.0   break 0; is no longer valid. In previous versions it was interpreted the same as break 1;.
    
    5.4.0   Removed the ability to pass in variables (e.g., $num = 2; break $num;) as the numerical argument.
    

提交回复
热议问题