Review Manual (4): process control

Time:2021-5-1

if…else

if(true){

do…while

$a = 0;

For (expression 1, expression 2, expression 3)

Expression 1: the loop is executed unconditionally and only once before it starts

$a = 0;

Expression 2: evaluated before each loop, true to continue the next loop, false to terminate the loop, if left blank, infinite loop (default is true)

$a = 10;
for( ; $a--; ){
    echo $a; //9876543210
}

Expression 3: execute after loop

$a = 10;
for( ; ; print_r($a)){ //987654321
    $a--;
    if($a == 0){
        break;
    }
}

foreach

$arr = array(

continue

Jump out of the current loop to the superior loop, the default is 1, that is, jump to the previous loop

for($x = 0; $ x < 1; $ x++){

switch

General structure:

switch($num){

Multiple choice structure:

switch($num){

return

The script terminates and returns null by default

function test(){
    return;
}
var_dump(test()); //NULL

This work adoptsCC agreementReprint must indicate the author and the link of this article

Recommended Today

Large scale distributed storage system: Principle Analysis and architecture practice.pdf

Focus on “Java back end technology stack” Reply to “interview” for full interview information Distributed storage system, which stores data in multiple independent devices. Traditional network storage system uses centralized storage server to store all data. Storage server becomes the bottleneck of system performance and the focus of reliability and security, which can not meet […]