Five. PHP language structure (2) loop structure

Source: Internet
Author: User
Tags php language

Cyclic structure learning objectives: while doing and for understanding their characteristics, and differences, remember several conditions of the loop. See code: &LT;? The php//while condition is true before running.      $i =0;while ($i <=10) {echo $i + +, ' <br/> '; Print out 0 to ten}//while ' when ' meaning. This expression means that when the value in parentheses is true, it is executed until it is false. So, we constantly change the value, let it stop for a fake.  This is a loop.   If the do condition is true or FALSE, perform a $i=100;do{echo ' I will do it once ';} while ($i <10); <? General elements of the Php/*for cycle: initialization (1), judging (2), Actuator (3), modifying variable (4) for (1;2;4) {3} *///For example: Rich people drink, ¥10w each drink 3W question: How many drinks can I have? Analysis: Initialize $I=10 judge each time to 3W, indicating $i>3 every drink, money will be reduced 3w//so $i-=3; ($i-=3 equals $i= $i-3 This is a shorthand) for ($i =10; $i >3; $i-=3) {echo ' drinks ';//print: Drink and drink drink}echo ' <br/> '; For ($i =1, $j =5; $i <=5&& $j >=1; $i + +, $j-) {echo $i, $j, ' <br/> ';//print: 15 24 33 42 51 * This example is very important, when you know it's going to be written. , you will understand the For loop. }

Five. PHP language structure (2) loop structure

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.