Home >> PHP >> If else / else if conditional statement in PHP

If else / else if conditional statement in PHP

The if else / else if condtional statement execute block of code when condition is true and another code execute condiotion false.

Syntax

if (condition){
       Code to be executed
}else if (condition){
       Code to be executed
}else{
       Code to be executed
}

Example

$a=5;
$b=3;
if($a>$b){
     echo "a is bigger than b";
}else if($a==$b){
     echo "a is equal to b";
}else{
     echo "a is smaller than b";
}

Post Your Comment

Next Questions
Switch conditional statement
For loop
While loop
Do while loop
Foreach loop
Operators
Arithmatic operators
Assignment operators
Increment / Decrement Operators
Comparision Operators
Logical operators
Array Operators
String
addcslashes() function
addslashes() function
chunk_split() function
crc32() function
explode() function
implode() function
join() function
ltrim() function
md5() function
metaphone() function
money_format() function
nl2br() function

Copyright ©2022 coderraj.com. All Rights Reserved.