Home  >  Article  >  Backend Development  >  Usage of php conditional statement if..else

Usage of php conditional statement if..else

藏色散人
藏色散人Original
2019-10-21 09:41:262380browse

Usage of php conditional statement if..else

Usage of php conditional statement if..else

PHP - if...else statement

To execute a block of code when the condition is true, and to execute another block of code when the condition is not true, please use the if....else statement.

Syntax

if (条件)
{
条件成立时执行的代码;
}
else
{
条件不成立时执行的代码;
}

If the current time is less than 20, the following example will output "Have a good day!", otherwise it will output "Have a good night!":

Example

Output:

Have a good day!

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of Usage of php conditional statement if..else. 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:What are PHP forms for?Next article:What are PHP forms for?