- A = 11;
- If (a> 10 ){
- Echo "a> 10 ";
- }
B. multi-branch: Basic syntax: If (conditional expression ){ Statement; //.....; } Else { Statement; //.....; } C. multiple branches: Basic syntax: If (condition expression) {statement; n statements;} else if (condition expression) {statement; n statements;} elseif (condition expression) {statement; n statements ;} eles {statement; n statements ;}Tip: 1. else if can have one or more. 2. the last else can have no D. switch branch statement Switch (expression) {case constant 1: Statement; n statements; Break; Case constant 2: Statement; n statements; Break; Case constant 3: Statement; n statements; Break; Default: Statement; n statements; Break ;} Note: 1. one or more case statements 2. defaul statements may not exist (according to the business logic of your own code) 3. generally, after a case statement, you must include a break, indicates exit switch statement 4. constant type (int, float, string, Boolean) Key point: The program is first configured in the case sequence. if none of them match, the program executes the content of the default statement until it encounters a break and then exits the switch; If and switch branch comparison: if determines a certain range, and switch determines a point, so we can choose them as follows: application scenario: swtich is used when the branch is a few points (such as determining the direction of the tank. When the branch is determined by several regions (ranges), use if. |