What is the difference between the include() and require() functions?

Asked: May 17, 2023

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 and cannot be found, it will only produce a warning (E_WARNING) and the script will continue the execution.

require() function:

The require() function performs the 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 and cannot be found, it will produce a fatal error (E_COMPILE_ERROR) and terminates the script.

Asked by brijesh

Answers (0)

No answers yet. Be the first to answer!