First, branch structure:
If statement:
if (conditional judgment) {
Statement block
}
If Else statement:
if (conditional judgment) {
Branch 1
}
else{
Branch 2;
}
Switch statement:
Switch (a data $v1) {//To determine if this V1 variable is equal to one of the following, and if it is equal, enter the corresponding process.
Case Status value 1:
Process 1
[Break;]
Case Status Value 2:
Process 2
[Break;]
Case Status Value 3:
Process 3;
[Break;]
。。。。。。
[Default:
The default process.
]
}
The use of punch, break is usually used, only some special data or requirements, may not be.
If break is not used, the process code in subsequent States will continue to be executed once a state is satisfied, and no longer judged.
Second, the cycle structure:
1. While loop:
$v 1 = 10;//initialization of the loop variable
while ($v 1〉4) {//Determine the condition of the loop variable
Statement Fast
echo "ABC";
$v;
}
Loop 3 Features:
1, loop variable initialization
2, cyclic variable judgment
3, cyclic variable change
This 3 feature usually applies to all loop procedures.
2. Do While loop
bo=
Loop body
}while (conditional judgment);
Meaning:
The loop body is executed first, then the condition is determined, and if the condition is met, the loop body is resumed and then judged, and so on.
3. For loop
for (conditional initialization, condition determination 2, Condition change 3): {
Loop Body}
4, the interruption of the cycle
Break Interrupt: Terminates the entire loop statement, and the statement that jumps out of the loop into the loop structure
Continue interrupt: Terminates the statement in the loop body that is currently executing, and enters into the next process of the loop (change, judge)
5, part of the process control of the replacement syntax:
if (...):
Statement block
endif
if (...):
Statement block
Else
Statement block
endif
if (...):
Statement block
ElseIf (...):
Statement block
ElseIf (...):
Statement block
Else
Statement block
endif
Switch (...):
Case ...
Case ...
Endswitch;
while (...):
Statement block
Endwhile;
for (...;;..):
Statement block
ENDfor;
foreach ():
Statement block
Endforeach;
6. Goto statement (jump statement)
Goto statements give programmers a great deal of freedom-seriously not recommended!
It allows our program to execute the process "any jump".
7. Control script Execution Progress
Die ("Output content")
Meaning: Terminates the operation of the PHP script (subsequent code is no longer executed) and outputs its contents
can also: Die ();d ie;
Exit is synonymous with die.
Die is a "language structure", not a function, you can not write parentheses.
Echo is also a language construct, not a function:
Echo ("abc");
echo "ABC";
echo "abc", "Def", 123;
Sleep ($n);
Meaning: Let the php script stop for $n seconds and then continue execution.
PHP Knowledge Point--Process Control