Home>Article>Backend Development> Usage of PHPelseif
PHP - if...elseif....else statement
Please use if.... elseif...else statement to execute different code based on two or more conditions.
Syntax
if (条件) { 条件为 true 时执行的代码; } elseif (condition) { 条件为 true 时执行的代码; } else { 条件为 false 时执行的代码; }
If the current time (HOUR) is less than 10, the following example will output "Have a good morning!", if the current time is less than 20, then output "Have a good day!" . Otherwise, "Have a good night!" will be output:
Example
Output:
Have a good morning!
For more PHP related knowledge, please visitPHP Chinese net!
The above is the detailed content of Usage of PHPelseif. For more information, please follow other related articles on the PHP Chinese website!