ProAnswers.org

What is the difference between include and require in PHP?

What is the difference between include and require in PHP?

The two functions are used to insert the content of a file into another PHP file before it is executed by the server. They are identical in every aspect, but they perform error handling in different ways. The include() function generates a warning (which does not halt execution) while the require() function generates a fatal error (which stops execution immediately).

If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue. require_once(), require(), include().