Home > DeveloperSection > Interviews > What’s the difference between include and require?

Posted on    March-18-2011 12:00 AM

 PHP PHP 
Ratings:
 1 Answer(s)
  947  View(s)
Rate this:

Sanjay Sharma
Sanjay Sharma

Total Post:42

Points:210
Posted on    March-18-2011 12:00 AM

Difference between include and require

It’s how they handle failures. 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.The key difference between require() and include() is that if you require() a file that can't be loaded (eg if it isn't there) then it generates a fatal error which will halt the execution of the page completely, and no more output will be generated. On the other hand, if you include() a file that can't be loaded, then this will merely generate a warning and continue building the page.

Modified On Apr-04-2016 01:09:07 AM

Don't want to miss updates? Please click the below button!

Follow MindStick