Pages

PHP - The if...else if....else Statement

Use the if....else if...else statement to select one of several blocks of code to be executed.

 

Syntax


if (condition)
  {
  code to be executed if condition is true;
 
}
else if (condition)
  {
  code to be executed if condition is true;
 
}
else
  {
  code to be executed if condition is false;
 } 
Example

<?php
$t=date("H");
if ($t<"10")
  {
  echo "Have a good morning!";
  }
else if ($t<"20")
  {
  echo "Have a good day!";
  }
else
  {
  echo "Have a good night!";
  }
?> 

No comments:

Flag Counter
| Copyright © 2013 Remote Tutor