You are here: Home / Topics / Difference between include () and require() function

Difference between include () and require() function

Filed under: PHP on 2022-10-09 08:25:52

include() function

This function is used to copy all the contents of a file called within the function, text wise into a file from which it is called.

When the file is included cannot be found, it will only produce a warning (E_WARNING) and the script will continue the execution.

require() function:

The require() function performs same as the include() function. It also takes the file that is required and copies the whole code into the file from where the require() function is called.

When the file is included cannot be found, it will produce a fatal error (E_COMPILE_ERROR) and terminates the script.

About Author:
S
Sikhar Chaudhary     View Profile
Learning is my hobby so I add new MCQs in this website for students.