Php loop statements in the basic tutorial of getting started with php

Source: Internet
Author: User
Tags add numbers getting started with php php programming language
Php loop statements in the basic tutorial of getting started with php
This section describes the php loop. The php loop statements include for, while, do .. while, switch, etc., should be the most used in actual programming, it is recommended that you firmly grasp.

Welcome to the php loop tutorial page. 1. break: indicates the process of stopping the current for, while, do... while, and switch. a number can be provided later to indicate the layer to which the switch flow is redirected. For example:

     "; Break; // jump out of the switch statement case 9: echo" quto to 9.
"; Break 2; // The number in the while loop cannot exceed the actual number of layers. if it is written as break 3, the system reports an error. Default: break;} echo 'over! $ I = '. $ I;?>

Result: quit to 4. quto to 9. Over! $ I = 9

2. continue statement: jump out of the remaining code in this loop and judge whether this condition is true for the next loop

     ";}Echo" Over ";?>

Result: $ I = 0 $ I = 1 $ I = 2 $ I = 3 $ I = 4 $ I = 6 $ I = 7 $ I = 8 $ I = 9 $ I = 10 $ I = 11 $ I = 12 Over

You can also add numbers after continue:

     ';}} Echo "Over" ;?>

Result: $ I = 0 $ j = 1 $ I = 1 $ j = 1 Over

3. goto statement: only jump syntax in the same file or scope: goto label; label: // .. statement

     

Output: bb

Thanks for your attention to the php getting started tutorial. this series of basic php tutorials will help new php beginners to quickly master the php programming language. The programmer's home will continue to provide php tutorials for you and wish you a better learning experience!

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.