The if...elseif...else statement


SUBMITTED BY: henry1874w

DATE: June 12, 2017, 4:10 p.m.

FORMAT: Text only

SIZE: 334 Bytes

HITS: 310

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. $t = date("H");
  6. echo "<p>The hour (of the server) is " . $t;
  7. echo ", and will give the following message:</p>";
  8. if ($t < "10") {
  9. echo "Have a good morning!";
  10. } elseif ($t < "20") {
  11. echo "Have a good day!";
  12. } else {
  13. echo "Have a good night!";
  14. }
  15. ?>
  16. </body>
  17. </html>

comments powered by Disqus