frijole Posted March 6, 2008 Share Posted March 6, 2008 Sometimes people use one and sometimes the other. Why? Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/ Share on other sites More sharing options...
drewbee Posted March 6, 2008 Share Posted March 6, 2008 include_once will throw a warning message if you try and include the same file more then once. require will stop script execution if it fails to load the file. Personally I always use require, as my scripts cannont run if they do not have the included file. Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485409 Share on other sites More sharing options...
frijole Posted March 6, 2008 Author Share Posted March 6, 2008 so if you say include functions.php and it fails for some reason the script will continue to execute. And, if you require it it will stop the script? Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485418 Share on other sites More sharing options...
rofl90 Posted March 6, 2008 Share Posted March 6, 2008 Yup with a fatal error, whereas include will give you a warning. Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485434 Share on other sites More sharing options...
frijole Posted March 6, 2008 Author Share Posted March 6, 2008 cool, thanks. Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485437 Share on other sites More sharing options...
trq Posted March 6, 2008 Share Posted March 6, 2008 This is all covered in the manual you know? Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485445 Share on other sites More sharing options...
Psycho Posted March 6, 2008 Share Posted March 6, 2008 There's a manual?! Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485460 Share on other sites More sharing options...
frijole Posted March 6, 2008 Author Share Posted March 6, 2008 Thanks, I'll check there more from now on. The problem is that occasionally the manual is over my head. Getting an answer through a conversation is much more effective, and interesting. Link to comment https://forums.phpfreaks.com/topic/94789-what-is-the-difference-between-include-and-require_once/#findComment-485464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.