homepage Welcome to WebmasterWorld Guest from 54.243.13.30
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Multiple include files vs one big include
Efficiency?
madmatt69




msg:3499980
 7:37 pm on Nov 8, 2007 (gmt 0)

Hey all,

Right now on my site I call 2 includes - a header.php and a footer.php.

A friend of mine suggested putting the code from both of those includes into one file, say 'includes.php' and then in my templates calling the code from the include as a variable.

Example, echo $header; and then echo $footer; in the appropriate places.

He said this would be more efficient because then the server only has to reference one file instead of two, even though the new includes.php file is bigger in file size.

I'm just wondering some of your opinions on this? Is it really more efficient?

 

ahmedtheking




msg:3500002
 8:02 pm on Nov 8, 2007 (gmt 0)

Well it all depends. Serving one file is always faster and in this case, it works fine for you. However, if you where to have a folder of function files, it would reduce performance by loading all of them instead of loading the ones you need when you need them. What you've got to remember is that the impact may just be milliseconds and you may not even notice!

darrenG




msg:3500038
 8:47 pm on Nov 8, 2007 (gmt 0)

All I would add to that is, if you know that you will always need both files, then they are better off as one file. the size of the file isnt relevant, because the two files would take up just as much memory as if they were just one file.

PHP_Chimp




msg:3500041
 8:49 pm on Nov 8, 2007 (gmt 0)

Could you use the auto_append_file [php.net] and auto_prepend_file, so that you dont need to worry about adding the code to each page manually?

This auto version treats the code as if it is required, so will produce fatal errors.
It will also call each file individually, however if this is a question about time taken to manually code then this may be a solution.
However some servers dont allow you to specify php directives in the htaccess file...so this may not work for you anyway, but could be worth a try.

[edited by: PHP_Chimp at 8:50 pm (utc) on Nov. 8, 2007]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved