Breaking

Saturday, February 29, 2020

How to use if else, nested if else condition in php 7?

If else condition is very useful i will also display you real world example of if else












<?php
$a= 2;
if($a == 2){
  echo "right";
}else{
  echo "wrong";
}
 ?>

Result :




Nested if else 

<?php
$percentage  = 70;
if($percentage >= 60){
  echo "first class";
}elseif ($percentage >= 50){
  echo "second class";
}elseif($percentage >= 35){
  echo "pass class";
}else{
  echo "fail";
}
 ?>

Result : first class 
 

Real world example : here I have used in my project, when process success it will display message with bootstrap theme 



You can see how i have used if condition in my project, Thank you




No comments:

Post a Comment

your suggestion are welcome by me