PHP If Else Statement

PHP If Else Statement Tutorial explains you How to use PHP Conditional Statements? with examples & Syntax.

While you are writing code, there are situations when you require to perform different actions for different conditions.

At this point you can write PHP conditional statements in your code.

PHP Conditional statements:

  • PHP if statement
  • PHP if else statement
  • PHP if elseif else statement
  • PHP switch statement

PHP if Statement

When you want to execute some code only if a specified condition is true, use PHP if statement.

Syntax for PHP if statement:

Example on PHP if statement:

Output will be:

PHP if else Statement

Utilize the if else statement to execute some code if a condition is true and an additional code if a condition is false.

Syntax for if else Statement in PHP:

Example on if else Condition in PHP:

Output  will be:

Previous articlePHP Operators
Next articlePHP switch case
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!