Javatpoint Logo

91-9990449935

 0120-4256464

PHP If Else

PHP if else statement is used to test condition. There are various ways to use if statement in PHP.

  • if
  • if-else
  • if-else-if
  • nested if

PHP If Statement

PHP if statement is executed if condition is true.

Syntax

Flowchart

php if statement flowchart

Example

Output:

12 is less than 100

PHP If-else Statement

PHP if-else statement is executed whether condition is true or false.

Syntax

Flowchart

php if-else statement flowchart

Example

Output:

12 is even number
Next TopicPHP Switch