Lesson 19 of 3063%

(Progress persistence is disabled until Phase 9)

PHP
Beginner

Elseif

Learn about Elseif in PHP.

PHP is a powerful server-side language. In this lesson, we will cover Elseif.

Real code examples

<?php
$time = date("H");

if ($time < "10") {
    echo "Have a good morning!";
} elseif ($time < "20") {
    echo "Have a good day!";
} else {
    echo "Have a good night!";
}
?>

Common mistakes

Make sure you include the <?php tag when writing PHP!

Try It Yourself

You can experiment with this in the Playground.

Lesson Progress

Take QuizBuild a PHP Project