Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why use PHP Includes other than for ease of editing 1

Status
Not open for further replies.

phpdreamer

Programmer
Nov 21, 2005
4
US
Why would I want to use php includes other than making it easy to edit one code that is used across the entire site. I mean, does it FOR SURE make the page load quicker? I'd really like to know,..has it been proven to make pages load faster for people?

I'm trying to figure this out so I can decide if I should complete this page I wrote in php so that I could use includes on everything that's on every single page.
 
Also, I do understand it saves space to just include one file instead of putting the code in each page..but other than that...does it load faster? better performance with includes?

Is there an ultimate reason to use includes if you don't have to worry about editing headers and footers globaly or about how much space you take up?
 
For me it's about maintaining a complete code base... a lot easier when common code is kept in seperate files. Regarding performance, I expect there will be a minor performance hit (a tiny tiny one)... I don't have any data to back that up.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Thanks for the reply..can anyone give concrete facts about performance?
 
IMHO most performance issues are rooted in inefficient coding or underpowered hardware.
Including shared libraries using include() with file system access is very quick and should not pose any significant performance loss.
Overall the maintenance of clean code, the use of classes, external modules, PEAR etc. leaves no other choice as to include code from other files.

The only thing to discourage is to include files using wrappers that e.g. fetch the content via http. As long as you use file system based includes you should be absolutely safe. The minor (probably not noticable) "loss" of performance is outweighed by the advantages of the organization of a code base. I'd look at it as a given - there is no other sensible way of coding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top