The code is given on page 650 as below:
Code:
<body>
<?php
date_default_timezone_set('UK/London');
if (date('G') >= 5 && date('G') <=11) {
echo '<h1>Good Morning!</h1>';
}
else if (date('G') >=12 && date('G') <=18) {
echo '<h1>Good Afternoon!</h1>';
}
else if (date('G') >=19 && date('G') <=4) {
echo '<h1>Good Evening!</h1>';
}
?>
</body>
However, the time is currently 21.48 and the page which is returned is blank. The reason is obviously that none of the above three else if statements are true. 21 is greater than 19 but is not less than or equal to 4 so obviously nothing is returned. Surely the last statement should be simply :
Code:
else {
echo '<h1>Good Evening!</h1>';
}
ie if the first two are false then just do this. I've amended my code to the above and it works fine with no error messages. My question is, is this correct programming or was I just lucky?
Thanks, Chastini.