use of else if in php

ElseIfExample.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>use of else if in php</title>
</head>

<body>
 <h2 style="color:orange; text-align:left;">use of else if in php example</h2>
 <?php
  /*
  |-------------------------------------------------
  | php checks for if first then else if than else
  |-------------------------------------------------
  */
  $name = 'cfsuman';
  if($name == 'iqbal') echo "Find you iqbal<br>";
  else if($name == 'suman') echo "Find you suman<br>";
  else echo "It must be cfsuman<br>";
  
  /*
  |-------------------------------------------------
  | if - else has chain so it is slow.
  | use switch it's faster
  |-------------------------------------------------
  */
 ?>
 
</body>
</html>


No comments:

Post a Comment

leave your comments here..