There are 6 kinds of control structure in PHP:
- If
- If (condition){Statements}
- Ternary operator
- (condition)?(Statement1):(Statement2)
- Switch
- switch(expression){
case value-1:
statements;
break;
case value-2:
statements;
break;
case value-n:
statements;
break;
case default:
statements;
break;
}
- While(or Do while)
- While(condition){statements;}
- Do{statements}While(condition);
- For
- For(initial-value;termination-check;loop-end-expression){statements;}
- Exit(or die)
- exit(”strings or number”);
- die(”strings or number”);
- Just terminate the script immediately after the exit(or die) function;


Leave a Reply