Example #1
0
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
function Greetings($hours)
{
    if ($hours >= 0 && $hours <= 12) {
        return "Good Morning.";
    } else {
        if ($hours > 12 && $hours <= 17) {
            return "Good Afternoon.";
        } else {
            if ($hours > 17 && $hours <= 20) {
                return "Good Evening";
            } else {
                return "Good Night";
            }
        }
    }
}
$hours = 13;
print Greetings($hours);
?>
    </body>
</html>
Example #2
0
<?php

function Greetings($hours)
{
    $hours = (int) $hours;
    $greetings = "";
    if ($hours < 11) {
        $greetings = "Goodmorning";
    } elseif ($hours < 14) {
        $greetings = "Good afternoon";
    } elseif ($hours < 18) {
        $greetings = "Good evening";
    } else {
        $greetings = "goodnight";
    }
    return $greetings;
}
print Greetings(12);
Example #3
0
<?php

print "<p>" . Greetings(0300) . '</p>';
function Greetings($hour)
{
    $hours = (int) $hours;
    if ($hour >= 00 && $hour < 1200) {
        return 'Good Morning';
    }
    if ($hour >= 1200 && $hour < 1700) {
        return 'Good Afternoon';
    }
    if ($hour > 1700) {
        return 'Good Evening';
    }
}
?>

Example #4
0
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
function Greetings($hours)
{
    if ($hours < 12) {
        return "Good Morning";
    } elseif ($hours > 12 && $hours < 17) {
        return "Good Afternoon";
    } elseif ($hours > 17 && $hours < 22) {
        return "Good Evening";
    } elseif ($hours > 22) {
        return "Good Night";
    }
}
print Greetings(6);
?>
    </body>
</html>
Example #5
0
<?php

function Greetings($hour = 0.0)
{
    if ($hour >= 5.0 && $hour < 12.0) {
        return 'Good Morning';
    }
    if ($hour >= 12.0 && $hour < 17.0) {
        return 'Good Afternoon';
    }
    if ($hour >= 17.0 && $hour < 20.0) {
        return 'Good Evening';
    }
    if ($hour >= 20.0 && $hour < 5.0) {
        return 'Good Night';
    }
}
print '<p>' . Greetings(23.0) . '</p>';
Example #6
0
<?php

function Greetings($hours)
{
    $hours = 2100;
    if ($hours <= 2400 && $hours >= 2000) {
        return "Good night!";
    }
    if ($hours >= 0600 && $hours < 1200) {
        return "Good morning!";
    }
    if ($hours >= 1200 && $hours < 1500) {
        return "Good afternoon!";
    }
    if ($hours >= 1500 && $hours < 2000) {
        return "Good evening!";
    }
}
print "<p>" . Greetings($hours) . "</p>";
Example #7
0
<?php

print Greetings(1300, "True");
function Greetings($hour, $test = '')
{
    $hours = (int) $hours;
    if ($hour >= 00 && $hour < 1200) {
        if ($test = 'True') {
            return "<h>" . 'Good Morning' . "</h>";
        } else {
            return "Good Morning";
        }
    }
    if ($hour >= 1200 && $hour < 1700) {
        if ($test = 'True') {
            return "<h>" . 'Good Afernoon' . "</h>";
        } else {
            return "Good Afternoon";
        }
    }
    if ($hour > 1700) {
        if ($test = 'True') {
            return "<h>" . 'Good Evening' . "</h>";
        } else {
            return "Good Evening";
        }
    }
}
?>