require, require_once, etc.
require, require_once, etc.
am 28.01.2008 03:41:25 von roberto
I read on a website recently that using require_once, although it
sounds like a nice idea, actually is processor expensive. But the guy
who posted that didn't say what else is faster:
* require
* include
* include_once
Which is fastest?
Re: require, require_once, etc.
am 28.01.2008 03:46:34 von Jerry Stuckle
Roberto wrote:
> I read on a website recently that using require_once, although it
> sounds like a nice idea, actually is processor expensive. But the guy
> who posted that didn't say what else is faster:
>
> * require
> * include
> * include_once
>
> Which is fastest?
>
Not much difference between any of the three, at least the first time
the file is included.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: require, require_once, etc.
am 28.01.2008 11:05:32 von Michael Fesser
..oO(Roberto)
>I read on a website recently that using require_once, although it
>sounds like a nice idea, actually is processor expensive.
Usually you won't notice any difference, if there is one at all in
recent PHP versions.
>But the guy
>who posted that didn't say what else is faster:
>
>* require
>* include
>* include_once
>
>Which is fastest?
Just use what fits your needs the best. If you encounter performance
problems, use a profiler to find the real bottlenecks in your code.
Micha
Re: require, require_once, etc.
am 29.01.2008 14:14:56 von colin.mckinnon
On 28 Jan, 02:41, Roberto <8...@myway.com> wrote:
> I read on a website recently that using require_once, although it
> sounds like a nice idea, actually is processor expensive. But the guy
> who posted that didn't say what else is faster:
>
> * require
> * include
> * include_once
>
> Which is fastest?
You missed out __autoload()
There's not a lot of difference in performance - there is a lot of
difference in the functionality - which should determine which you
use. RTFM
How you use include files in general all rather depends on the scale
of your application in terms of lines of code and traffic volumes.
IME it's not particularly CPU intensive but having a lot of includes
can use up more memory than if the code were inline - but splitting
code into multiple files makes it easier to only load the code you
need (saving memory and CPU) and (unless you are Google, this next one
is typically the decider) makes managing your code much easier.
IIRC there used to be a tool out there which would inline code
automatically - a sort of precompiler. But I suspect it won't handle
all the scenarios that would be resolved by an explicit include or
__autoload
C.