Php if else statement

if-Else statement
As it’s name implies, elseif () works similar to if () and else () statements. However, using elseif () gives you more than two possible outcomes. Unlike else () which executes in all cases the if () is false… elseif () only executes if the statement is true.

  • If statement – use this statement to execute some code only if a specified condition is true
  • if…else statement – use this statement to execute some code if a condition is true and another code if the condition is false
  • if…elseif….else statement – use this statement to select one of several blocks of code to be executed
<?php
 IF (conditional statement) 
{ 
[code if condition is true] 
}
 ELSE 
  {
  [code if condition is false]
  }
 ?>
 

Example

<?php
 if ($x > $y) 
 { 
 echo "x is larger than y"; 
 } 
 elseif ($x == $y) 
 { 
 echo "x is equal to y"; 
 } 
 else 
 { 
 echo "x is smaller than y"; 
 } 
 ?>
free porn sites

Admin has written 171 articles