Register|Login

Have a question? Click here to ask the community.

Quiz 8 – Include

| In: PHP Quizzes | 21,224 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. A common practice for naming files that are to be included is to use the .php extension?

True
False

2. The include command takes a file name and simply inserts that file’s contents into the script/document that issued the include command?

True
False

3. Which of the following is the correct way to use the include command?

include(“example.php”)
include “example.php”;
include(“example.php”);
None of the above

4. Based on the following two files, index.php and content.php, what will be displayed in your browser when visiting index.php?

File content.php contains:
<?php
echo “Hello World”;
?>

File index.php contains:
<html>
<body>
<?php
include(“content.php”);
?>
<br>Hello Earth
</body>
</html>

Hello World
Hello Earth

Hello Earth
Hello World

Hello World
Hello Earth

5. Based on the following two files, index.php and content.php, what will be displayed in your browser when visiting index.php?

File content.php contains:
<?php
echo “Hello World”;
?>

File index.php contains:
<html>
<body>
<br>Hello Earth
<?php
include(“content.php”);
?>
</body>
</html>

Hello World
Hello Earth

Hello Earth
Hello World

Hello World
Hello Earth



4 Responses to Quiz 8 – Include

Avatar

purplravioli

May 6th, 2016 at 1:53 pm

Technically, shouldn’t the correct answer to quiz question 5 be: Hello EarthHello World There’s a new line printed BEFORE Hello Earth, but not between the two.

Avatar

brooke

November 26th, 2016 at 3:39 pm

Avatar

brooke

November 26th, 2016 at 3:40 pm

include ‘vars.php’;

Avatar

kaacyn

May 31st, 2017 at 11:41 am

include “example.php”; Also correct.

Comment Form

You must be logged in to post a comment.

Users Online

Users Online: 2 Users

Most Users Ever Online: 91

Quiz Scores

Advertisments