What is the difference between include and require ?

The both functions “include” and “require” is used include the file to the PHP Page.

The base difference between the “include()” and “require()”  is that the “require()” give the fatal error and halt the execution of the program when the required pages are not available.

Where as

The “include()” function only gives the warning message and continue the execution of the program even the required  pages is not found or available .

The various way to include the file to the pages :

 In case of include() and  require() you can re-declared the same page multiple times

where as include_once() and require_once() evaluate the multiple existence of file , if file  exist do not allow  you the include the same file multiple times .

In the same way include_once() create warning messages where as require_once() gives fatal error and halt the execution of the program .

Leave a Reply

Your email address will not be published.Required fields are marked *