1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which of the following is the correct way to include an…

Added 23 Jan 2024

Which of the following is the correct way to include an external PHP file?

  1. include("file.php"); Correct answer
  2. require("file.php");
  3. import("file.php");
  4. load("file.php");

Correct answer

A. include("file.php");

15 views

MCQSEXAM

Explanation

include("file.php"); inserts and runs the contents of another PHP file. require("file.php"); is equally valid syntax; the difference is in error handling — include raises a warning and carries on if the file is missing, while require stops the script with a fatal error.

import() and load() are not PHP statements.

Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs