pornophobic Posted May 27, 2010 Share Posted May 27, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/203082-overhead-with-include-and-require-functions/ Share on other sites More sharing options...
ScotDiddle Posted May 27, 2010 Share Posted May 27, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/203082-overhead-with-include-and-require-functions/#findComment-1064129 Share on other sites More sharing options...
Alex Posted May 27, 2010 Share Posted May 27, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/203082-overhead-with-include-and-require-functions/#findComment-1064137 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.