Firefox PHP

Simple piece of php fits nicely into phorum

Posted by Danielus 
Simple piece of php fits nicely into phorum
September 01, 2007 02:08AM
I am not expert with PHP, but I am learning!

I implemented basic, but fun piece of code on my site to greet people (Good Evening/Afternoon/Morning/ and Late Shift). If you could benefit from this code on your phorum sites, use it and enjoy it:

<?

$afternoon = "Good afternoon! blablablah";
$evening = "Good evening! blablablah";
$late = "Glad to see you so late! blahblahblah";
$morning = "Good morning! blahblahblah";

//Get the current hour
$current_time = date(G);

// between 12:00 p.m. and 4:00 p.m.
if ($current_time >= 12 && $current_time <= 16) {
echo $afternoon;
} 
// between 5:00 p.m. and 11:00 p.m.
elseif ($current_time >= 17 && $current_time <= 24) {
echo $evening;
}
// between midnight and 5:00 a.m.
elseif ($current_time >= 1 && $current_time <= 5) { 
echo $late;
}
// between 6:00 a.m. and 11:00 a.m.
elseif ($current_time >= 6 && $current_time <= 11) { 
echo $morning;
}

?>
Sorry, only registered users may post in this forum.

Click here to login