Which of the following is the correct way to include an external PHP file?
Correct answer
A. include("file.php");
15 views
A. include("file.php");
15 views
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.
Not sure why the answer is A? Ask here and get an explanation.