Jump to content

Overhead with include and require functions


pornophobic

Recommended Posts

I'm writing an application, for my personal site, and I've mainly studied the code of phpFox. Now, phpFox is a great script as it is, but it's made to be installed on a server, either windows or Linux. I want mine to make better use of the server resources as it'll all be static and certain things won't have to change like they would on a pre-made script like that.

I do have SOME variables so I can test locally and just upload to the site. The thing I'm trying to ask here is I notice that the pre-made scripts (I've read through more than one) have TONS of file includes and requires. I understand the purpose of these, so that all the classes are pretty much available throughout the whole script. I'm wondering what the overhead is like on these includes and requires?

Would there be less overhead if I used the _once versions?

Is it even worth being concerned about? I have 4GB RAM and 2.6 Ghz for one site... I do expect there to be a surge of teenage users when the site is launched, so I'm just wondering if I should be concerned about include overheads or not, since they like to 'spend' lots of time on websites like I am making.  8)

Link to comment
Share on other sites

pornophobic,

 

    Whereas I understand the difference between require and include, if your script dosen't "NEED" the inclcuded script to operate correctly, then include is fine.  If the included file is absolutely required for your script to run correctly, use require.

 

    If you are including a script which have classes or functions, require_once and include_once insures that if the fucntions or classes in the included script are already available, then don't include/require them again... If they are included again, you will get a fatal error stating that the functions / classes in your newly inserted script already exitst, and cannot be re-defined.

 

    I do not know of the performance difference between the two types ( include/include_once, require/require_once ).

 

    Hope this helps.

 

Scot L. Diddle, Richmond VA

Link to comment
Share on other sites

require_once and include_once have more overhead than require and include. In most cases the slight overhead isn't something you should concener yourself with because of how small it is. You should use what is best for your specific situation. If you have a case where a file only needs to be included once, and shouldn't be included more than once, use include_once or require_once.
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.