delickate Posted August 29, 2008 Share Posted August 29, 2008 What's the difference between "include", "include_once", "require", "require_once"? plz guide me with examples thanx Link to comment https://forums.phpfreaks.com/topic/121855-help-plzdifferences/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 29, 2008 Share Posted August 29, 2008 The php manual explains each of those better and in more detail than anyone could in a forum. Link to comment https://forums.phpfreaks.com/topic/121855-help-plzdifferences/#findComment-628676 Share on other sites More sharing options...
DeanWhitehouse Posted August 29, 2008 Share Posted August 29, 2008 In basic include - will include the chosen script, and if not found will produce a non fatal error include_once - will do the same as include but will only include the file once , therefore if you put include for the file more than once in the code it wont include it more than once. require - like include , but will produce fatal error require_once - same as include_once , but again fatal error Anyone correct me if im wrong with anything Link to comment https://forums.phpfreaks.com/topic/121855-help-plzdifferences/#findComment-628686 Share on other sites More sharing options...
compguru910 Posted August 29, 2008 Share Posted August 29, 2008 With the include function, if the file cannot be loaded for whatever reason, the page will continue to load as well as the script. The include once will include the file (if it can be found, and only ran once [incase of functions]). Require, is pretty much self explanatory. With the require function, if the file cannot be loaded, the page will cease to write, and you will get an error. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/121855-help-plzdifferences/#findComment-628744 Share on other sites More sharing options...
Eggzorcist Posted August 29, 2008 Share Posted August 29, 2008 I suggest using require for any authentication scripts or security you want to include. Less important things, use include. That said, I just use require. As, files don't normally vanish so you won't get the error with a live website, plus it's better for testing you're script so you can see if there is an error. If you have any doubts about functions you can try php.net first. It has them all! Link to comment https://forums.phpfreaks.com/topic/121855-help-plzdifferences/#findComment-628780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.