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