SCook Posted August 27, 2007 Share Posted August 27, 2007 Hi all, What is the difference, or best times to use, include(), require() and require_once()? Because essentially, they do the same thing, but thee could be some subtlety I'm not aware of. Link to comment https://forums.phpfreaks.com/topic/66893-difference-between-include-require-and-require_once/ Share on other sites More sharing options...
trq Posted August 27, 2007 Share Posted August 27, 2007 Its all explained in the manual. Link to comment https://forums.phpfreaks.com/topic/66893-difference-between-include-require-and-require_once/#findComment-335326 Share on other sites More sharing options...
chocopi Posted August 27, 2007 Share Posted August 27, 2007 They all do the same thing except when the path is incorrect include will: give error but carry on loading. require will: give fatal error and stop loading. The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. They both produce a Warning' date=' but require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well. Be warned that parse error in included file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does.[/quote'] Using _once will stop the file from being loaded multiple times, like in a loop etc, But as Thorpe said, use the manual ~ Chocopi Link to comment https://forums.phpfreaks.com/topic/66893-difference-between-include-require-and-require_once/#findComment-335328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.