php The usage of if statement is: 1. if else statement. If the condition is not true, the code block after else will be executed; 2. [if (condition) {code whether to execute...}] is commonly used To judge a single condition.
php The usage of if statement is:
1, if (condition) {whether it is executed Code...}
: This usage is often used to judge a single condition. Of course, multiple conditions can be combined into the same condition using logical symbols.
2. if else statement
: If the condition is not established, the code block in {} after else will be executed.
3, if else if... statement
: Use the format if (condition 1) {the code block to be executed if condition 1 is true, and the subsequent conditions will not be ignored}elseif( Condition 2) {If the previous condition is not true, continue to judge condition 2. If condition 2 is true, execute this code block, and the subsequent judgments will be ignored}...; There is no limit to the number of elseifs, but the code block is the most Only one will be executed. If the previous condition is established, the subsequent condition will be ignored.
4, if else if...else
: A situation processing for the if elseif... statement. This situation is that if none of the previous conditions is true, then The code block in {} after else will be executed.
Related learning recommendations: php programming (video)
The above is the detailed content of What is the usage of php if statement. For more information, please follow other related articles on the PHP Chinese website!