Register|Login

Have a question? Click here to ask the community.

Quiz 13 – Else If Statements

| In: PHP Quizzes | 14,084 views

*You are currently not logged in and your quiz score will not be recorded. Please login or register if you would like to submit your quiz score.

Directions: Answer all questions. Any questions skipped will be scored as wrong answers. Good Luck! 🙂

1. What will be displayed in a browser when the following PHP code is executed:

<?php
   if (8 <= 7) {
       echo "Hello World";
   }
   elseif (9 == 9) {
       echo "Hello Robert";
   }
   else
       echo "Hello YouTube";
   }
?>

Hello World
Hello YouTube
Hello Robert
Nothing Will Be Displayed

2. The PHP Else If Statement must be preceded by an If Statement before it can be used?

True
False

3. What will be displayed in a browser when the following PHP code is executed:

<?php
   if (8 >= 7) {
       echo "Hello World";
   }
   elseif (9 == 9) {
       echo "Hello YouTube";
   }
?>

Hello World
Hello YouTube
Hello World Hello YouTube
Nothing Will Be Displayed

4. What will be displayed in a browser when the following PHP code is executed:

<?php
   $bookColor = "blue";
   if ($bookColor == "red") {
       echo "You have a red book";
   }
   elseif ($bookColor == "blue") {
       echo "You have a blue book";
   }
?>

You have a blue book
You have a red book
Nothing Will Be Displayed

5. What will be displayed in a browser when the following PHP code is executed:

<?php
   $x = 6;
   if ($x ==  10) {
       echo "I have $x dollars";
   }
   elseif ($x > 7 && $x < 10) {
       echo "I have $x children";
   }
   elseif ($x == 20) {
       echo "I have $x pieces of candy";
   }
   else {
       echo "I have $x footballs";
   }
?>

I have 6 footballs
I have 6 dollars
I have 6 children
I have 6 pieces of candy

Comment Form

You must be logged in to post a comment.

Users Online

Users Online: 1 User

Most Users Ever Online: 91

Quiz Scores

Advertisments