I have a variable, $h, that contains the hour (in military time) that an entry was posted. I'd like to echo a user-friendly time-of-day label depending on the value of $h. (For example, if $h is 13 -- ie, the post was entered in the 1 PM hour -- I'd like it to print "Early afternoon".) So I basically need to set up a series of if statements. This is what seems logical to me...
(Obviously there will be more, as I stopped at 3 PM, but until I get it to work, this is the basic idea.) The above code produces this error:PHP Code:if ($h = 0) { $x = "The midnight hour";}
elseif (1 <= $h <= 4) { $x = "Wee morning hours"; }
elseif (5 <= $h <= 7) { $x = "Early morning"; }
elseif (8 <= $h <= 10) { $x = "Mid-morning"; }
elseif ($h = 11) { $x = "Late morning"; }
elseif ($h = 12) { $x = "Lunchtime"; }
elseif (13 <= $h <= 14) { $x = "Early afternoon";}
elseif ($h = 15) { $x = "Mid-afternoon";}
echo $x;
which indicates to me that I just don't have the syntax right. Can someone set me straight?Parse error: parse error, unexpected T_IS_SMALLER_OR_EQUAL in /home/hsphere/local/home/blitchre/journal.gobecky.com/index.php on line 86




Bookmarks