Home>Article>Backend Development> Usage of PHPelseif

Usage of PHPelseif

藏色散人
藏色散人 Original
2019-10-21 09:55:37 3070browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Can php write software? Next article:Can php write software?