Table of Contents
<h2>if...else_Statement</h2>
<p>The if...else statement executes some code if a condition is true and another code if that condition is false.</p>
<?php
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Result View Example
<h2>if...elseif...else Statement</h2>
<p>The if...elseif...else statement executes different codes for more than two conditions. </p>
<?php
// $t = date("H");
$t = 19;
echo "<p>The hour (of the server) is " . $t;
echo ", and will give the following message:</p>";
if ($t < "10") {
echo "Have a good morning!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Result View Example
Document in project
You can Download PDF file.