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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.