if else statement - how to use if else statement (condition) in php

if else statement - how to use if else statement (condition) in php


ifelsestatement.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=utf-8" />
<title>if else statement - how to use if else statement (condition) in php</title>
</head>

<body>
    <h2 style="color:Seagreen; font-style:italic">php example: using if else statement (if else condition)</h2>
    <hr width="525" align="left" color="Green" />
    <br />

<?php 
 $ColorName="MistyRose";
 
 if($ColorName == "Crimson")
 {
 echo "<div style='Color:Snow;Background-color:Crimson;height:125px; width:375px;padding-left:35px;font-size:x-large;'>";
  echo "<br />";
  echo "selected color is: crimson";
 echo "</div>";
  }
 else
 {
 echo "<div style='Color:Snow;Background-color:LightPink;height:125px; width:375px;padding-left:35px;font-size:x-large;'>";
  echo "<br />";
  echo "There is no selected color.";
 echo "</div>";
  }
?>

</body>
</html>