0

What's wrong with this PHP code

Just started learning PHP and am at decision making. I tried this but I see parse error <?php $time = date('G'); If ($time>=5 && <=7){ Echo 'please continue sleeping'; } elseif ($time>=8 && <=12){ echo 'you ought to be at work'; } elseif ($time >=13 && <=18){ echo 'good day'; } elseif ($time>=19 && <=23){ echo 'have some rest'; } else { echo 'why are you awake'; } ?>

15th Dec 2017, 6:02 AM
Chinedu Chiaju
Chinedu Chiaju - avatar
5 Answers
+ 4
Try this: <?php $time = date('G'); If ($time>=5 && $time<=7){ echo 'please continue sleeping'; } elseif ($time>=8 && $time<=12){ echo 'you ought to be at work'; } elseif ($time >=13 && $time<=18){ echo 'good day'; } elseif ($time>=19 && $time<=23){ echo 'have some rest'; } else { echo 'why are you awake'; } ?>
15th Dec 2017, 6:14 AM
CalviÕ²
CalviÕ² - avatar
+ 3
1.) if needs to be lowercase 2.) You need to have complete comparisons on each side of an OR || or an AND && <?php $time = date('G'); if ($time >= 5 && $time <= 7) { Echo 'please continue sleeping'; } elseif ($time >= 8 && $time <= 12) { echo 'you ought to be at work'; } elseif ($time >= 13 && $time <= 18) { echo 'good day'; } elseif ($time >= 19 && $time <= 23) { echo 'have some rest'; } else { echo 'why are you awake'; } ?>
15th Dec 2017, 6:11 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
It's working.... Thanks
15th Dec 2017, 6:21 AM
Chinedu Chiaju
Chinedu Chiaju - avatar
0
Yea
15th Dec 2017, 6:09 AM
Chinedu Chiaju
Chinedu Chiaju - avatar
0
@Choatic It didn't workout. Or is the play ground on solo learn rejecting some codes?
15th Dec 2017, 6:17 AM
Chinedu Chiaju
Chinedu Chiaju - avatar