Re: Mixing eval() with include/require

From: Date: Fri, 22 Dec 2000 14:57:14 +0000
Subject: Re: Mixing eval() with include/require
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31562@lists.php.net to get a copy of this message
> Tim Zickus wrote: > > I would try something like: > > > > $expr = implode(" ",file("test$id.inc")); > > > > and in your loop, do "eval($expr)". > > > > This way it only gets included once. > > Thanks for this suggestion; I'll experiment along these lines when I get > chance. > > What overhead is there for the eval()? Eg, what difference would there be > between: > MyFunc(); > and > eval('MyFunc();'); > Note that the function is being called repeatedly in a loop so small > differences can mount up. As long as it's insignificant compared with the > time taken by MyFunc() itself I'll be okay. eval() does about the same thing an include does. So it isn't going to be much faster. I really don't understand why you don't just use an include file with functions and then call the function inside the loop. This is exactly what functions are for. Including a file repeatedly inside a loop, or calling eval() repeatedly is not a good approach. -Rasmus

« previous php.general (#31562) next »