|
I have found that are some other differences in include() vs require()
include() = more resource hungry with heavy server load and low memory
require() = much much less load on the server
here is an example, include() reads the php and evaluates it, require just dumps that bit of code into your page that required it and evals all at the same time.
Imagine you have 5 include on a page, php looks like it does the following...
include1() ... reads ... evals
include2() ... reads ... evals
include3() ... reads ... evals
include4() ... reads ... evals
include5() ... reads ... evals
whereas require dumps all 5 into the main php file and then evals all the code in one go. Imagine you have a few hundred users all simultaneously loading php pages with these includes, you wouldn't really notice except if you try to then load a larger flat file database or something else that may hit your memory with a heavy load at the same time. with the include() you will see it will take a lot lot longer to load the flat file, switch them to requires and your load time will drop dramatically.
I am still trying to think of an instance where you would want to use include over require... I havent yet.
just some observations...
|