Jump to content

include() vs include_once()


tricky_dicky

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/239231-include-vs-include_once/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.