if Statement
Syntax
if (condition) {
code to be executed if condition is true;
}
if...else Statement<?php
$t = rand(1,10);
if ($t < "3")
{
echo "Hi! ".$t;
}
?>
if...elseif...else Statement<?php
$t = rand(1,10);
if ($t < "3")
{
echo "Hi! ".$t;
}
else
{
echo "Hello ".$t;
}
?>
<?php
$t = rand(1,10);
if ($t < "3")
{
echo "Hi! ".$t;
}
elseif ($t < "7")
{
echo "Hey ".$t;
}
else
{
echo "Hello ".$t;
}
?>