Do web pages load faster or load slower when all headers, footers and basic functions are placed in external files and called using the statements below?
There's no noticable performance issue. Check out the metrics in this blogpost, which are simple enough to recreate on your own. The results are:
Running for 1000 files: require, require_once, include_once, include
faster by og. time
include_once: n/a 0.088193
require_once: + 0.013137 0.101330
require: + 0.030759 0.118952
include: + 0.045299 0.133492
The benchmark is more geared towards comparing the functions, but it's evident that the times are extremely small. This other benchmark shows:
[11-Jan-2008 11:31:57] Benchmark include 0.039840936660767
[11-Jan-2008 11:31:57] Benchmark require 0.05462384223938
Also for 1000 files. So apparently, the performance penalty is minimal. At heart both
require() and their
_once() equivalents are simple filesystem reads, nothing special about them that would hint towards a performance concern.
Bear in mind that if you find includes to be slow, you might have stumbled upon a bug. The one I've linked to is closed, but you never know. A good hint is the first answer to the bug:
The include process is identical on all Win32 systems, any slowdowns are likely to be related to either the drive speed or the OS internals.
That said one of the reasons you are getting such bad numbers is because you are using a partial path PHP needs to resolve first. This compounded with ZTS mode makes things very slow, change the include statement to use full paths and you'll see much improved performance, not to mention much more consistent numbers.
It didn't make any difference with the bug, but you should always have it in mind, if you are going for thousands of includes.
Are there any other benefits to separating such content?
Yes, of course. You have one file for your functions, one for your header and one for your footer, which means that you don't have to rewrite them every time you need them. Isn't that enough? Don't repeat yourself.