Home / PHP/MySQL Tutorials / Language Basics / Archive by category 'IF/ELSE Statement'

IF/ELSE Statement

Find maximum of three numbers using IF ELSE in PHP

<?php
$x=10;
$y=20;
$z=30;
if($x > $y)
{
   if($x > $z)
   {
      echo("The maximum number is ");
      echo("$x<p>");
   }
   else
   {
      echo("The maximum number is ");
      echo("$z<p>");
   }
}
else
{
   if($y > $z)
   {
      echo("The maximum number is ");
      echo("$y<p>");
   }
   else
   {
      echo("The maximum number is ");
      echo("$z<p>");
   }
}
?>