tricky_dicky Posted June 13, 2011 Share Posted June 13, 2011 Hi Guys and Gals, Can anyone explain to me what the difference is between include and include_once? Ive read this: http://php.net/manual/en/function.include-once.php The contexts of this query is that I want to create a global config file (just a regular php script chock full of variables that I can call across the board but a friend has advised me instead of include, i should use include_once. But I'm afraid I don't understand, I'm very new to PHP, so please be gentle!! Modified: spelling errors / typos Thanks Tricky Quote Link to comment https://forums.phpfreaks.com/topic/239231-include-vs-include_once/ Share on other sites More sharing options...
monkeytooth Posted June 13, 2011 Share Posted June 13, 2011 There is no true difference in what the do, with exception of if you happen to include the same file within a set of files more than once it will ignore it the second, thrid, forth, time it is attempted to be loaded. Most people put there sites together in a template format similar in nature to that of which you imply your attempting to do. they will call several files into an index.php to do various things but want to keep them all separate for easier editing down the road. However sometimes people will make an index2.php that loads various other files up to and including one or more of which index.php may have loaded into it, then include within index.php index2.php Quote Link to comment https://forums.phpfreaks.com/topic/239231-include-vs-include_once/#findComment-1229048 Share on other sites More sharing options...
tricky_dicky Posted June 13, 2011 Author Share Posted June 13, 2011 Thanks for the reply monkeytooth! Quote Link to comment https://forums.phpfreaks.com/topic/239231-include-vs-include_once/#findComment-1229097 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.