PHP Basics Tutorial PHP Looping statements

Source: Internet
Author: User
Tags add numbers php basics php programming
This section introduces the PHP loop, and PHP's looping statements include for, While,do. While,switch, etc., in the actual programming should be the most, it is recommended that we firmly grasp.

Welcome to the PHP Cycle tutorial page. 1. Break: Indicates the end of the current for, While,do. While,switch process, you can give the number, indicating the return to the first layer. Such as:

 
      "; break;//jump out of the switch statement case 9:echo" Quto to 9.
"; Break 2; Here jumps 2 layers, jumps out the while loop here the number cannot exceed its actual layer number, if writes the break 3, the system will error. Default:break;}} Echo ' over! $i = '. $i;? >

Result: Quit to 4.quto to 9.over! $i =9

2, continue statement: Jump out of this cycle of the remaining code, and judge this condition is true when the next cycle

 
      ";} echo "Over";? >

Results: $i =0$i=1$i=2$i=3$i=4$i=6$i=7$i=8$i=9$i=10$i=11$i=12over

You can also add numbers after continue:

 
      ';}} echo "Over";? >

Results: $i =0$j=1$i=1$j=1over

3, goto statement: can only be in the same file or scope to jump syntax: goto tag; Tags://. Statement

 
      

Output: BB

Thank you for your attention to the PHP introductory tutorial, this series of basic PHP tutorial will help PHP novice friends, quickly master the language of PHP programming. The programmer's home will continue to introduce PHP-related tutorials For everyone, I wish you all the progress of learning!

  • Related Article

    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.