PHP function continue usage in loop structure _php tutorial

Source: Internet
Author: User
We are in the actualPHP function Continue is unique in that it takes an optional numeric parameter to decide to skip a few loops to the end of the loop.

In PHP, continue is used in the loop structure to skip the remaining code in the loop and start the next loop. This is consistent with other languages, but there is another beauty: Continue accepts an optional numeric parameter to decide to skip a few loops to the end of the loop.

 
 
  1. #php_continue. php
  2. $ I = 0 ;
  3. $ J = 0 ;
  4. While ($i + <3) {//level 3
  5. echo "Outer
  6. n ";
  7. while (1) {//level 2
  8. echo "Middle
  9. n ";
  10. while (1) {//level 1
  11. echo "Inner
  12. n ";
  13. Continue 3;
  14. }
  15. echo "Thisnever gets output.
  16. n ";
  17. }
  18. echo "Neither does this.
  19. n ";
  20. $j + +;
  21. After Runscontinue 3,it comes to the end of level 3
  22. }
  23. echo "$ J = $j ";//output: $ J = 0
  24. ?>

The above code, is the PHP function continue the specific use, I hope to help you.


http://www.bkjia.com/PHPjc/446358.html www.bkjia.com true http://www.bkjia.com/PHPjc/446358.html techarticle What differentiates us from the actual PHP function continue is that we accept an optional numeric parameter to decide to skip a few loops to the end of the loop. In PHP, continue is used in the loop structure to ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.