For statement changes

Source: Internet
Author: User

In the process of software development, you sometimes need to use multiple forms of for statements flexibly. Other forms of for statements are listed in the example code!
// The first change extracts the first part of the for Loop syntax
<? Php
$ I = 1;
For (; $ I <2; $ I ++) {// The first semicolon cannot be omitted.
Echo "This is the first output". $ I! </Br> ";
}
?>
 
// For the second change, extract the first part of the for Loop syntax, and put the increment of the third part into the for loop body.
 
<? Php
$ I = 1;
For (; $ I <2;) {// The first semicolon cannot be omitted
Echo "This is the first output". $ I! </Br> ";
$ I ++;
}
?>
 
// In the third change, all for loop syntax is omitted.
<? Php
$ I = 1;
For (;) {// The first semicolon cannot be omitted
If ($ I> 1)
Break;
Echo "This is the first output". $ I! </Br> ";
$ I ++;
}
?>
All programs have been tuned in Apache 2.2 + PHP5.2.6!
 
If the program is poor, it will be changed, and the general principles will be reached. It seems that there is also such a philosophy in the program!



From the column in chuoyue05

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.