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'; } ?>
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';
}
?>
+ 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';
}
?>
+ 3
It's working.... Thanks
0
Yea
0
@Choatic
It didn't workout.
Or is the play ground on solo learn rejecting some codes?