PHP Learning Note--4. Control structure

Source: Internet
Author: User

Directory:

PHP Learning note--1. variables

PHP Learning note--2. Constants

PHP Learning note--3. operator

PHP Learning Note--4. Control structure

PHP Learning Note--5. Functions

1. Sequential structure

Execute from top to bottom in writing order

2. Branching structure

① Single-channel if

② two-way if. Else

③ Multi-path IF. else if: Else

④ multi-path switch. Case

Switch ($day) {

Case 1:echo ' Monday ';

Break

Case 2:echo ' Tuesday ';

Break

...

Default:echo ' Sunday ';

}

NOTE: switch. Case can only be for the exact value

And if.. else if: Else can be used to determine the scope after adding a condition

3. Cyclic structure

①while

An initial expression;

while (conditional expression) {

an evaluation expression;

Execute the statement;

}

Note: If the first cycle condition is false, it is not executed once

②do. While

An initial expression;

do {

an evaluation expression;

Execute the statement;

} while (conditional expression);

Even if the condition is false, it will be executed once

③for (initial expression, conditional expression, evaluation expression) {

Execute the statement;

}

④break and Continue

Break breaks the loop, jumps out of the loop

Continue interrupts this time, jumps to the next loop

4. File operation

Include (), if the introduced file does not exist, the view continues to execute down

Require (), if the introduced file does not exist, no longer continues execution

Header ("Content-type;text/html;charset=utf-8"); Set character sets

@zhnoah
Source: http://www.cnblogs.com/zhnoah/
This article is owned by me and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original
The right to pursue legal liability.

PHP Learning Note--4. Control 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.