frijole Posted March 6, 2008 Share Posted March 6, 2008 Sometimes people use one and sometimes the other. Why? Quote 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. Quote 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? Quote 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. Quote 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. Quote 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? Quote 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?! Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.