Yes, Rob is right. My original question is about the difference between the
processing of a file-based site with include() OR eval(). In that case, if I
understood it correctly, the results are the same.
But! If the included pages contain functions, classes, etc. With eval(), can
I use them? With include(), I know I should be able to use them. But in some
mysterious cases I don't have access to a function. If I cut out from the
included file, and put in on the file which includes that, just before (or
after) the includ(), I don't have any problem with it.
The next step, that if I include a file in a function, can I use the
functions wrote in the included file?
As I know, include just makes a copy-paste, so if I use it IN a function,
then all function will be in function scope, am I right?
----- Original Message -----
From: "Robert Cummings" <rob...@interjinn.com>
To: "Virgilio Quilario" <virgilio.quila...@gmail.com>
Cc: "Sándor Tamás (HostWare Kft.)" <sandorta...@hostware.hu>;
Sent: Wednesday, March 11, 2009 1:55 PM
Subject: Re: [PHP] Silly question - include vs. eval
On Wed, 2009-03-11 at 20:49 +0800, Virgilio Quilario wrote:
>> I wondering what is the difference between include(), and eval('
>> ?>'.file_get_content().' <?php ')?
>> If there is something I should be aware, please, let me know.
> Use include since it allows a cache like eAccelerator or APC to work.
> Eval never gets cached. Also, include let's the engine do the opening,
> reading, closing of the file while also parsing and running the
> in one fell function call (yes I know it's not a function). What you
> have above, using eval, is a bastardization of cleanliness and
> succinctness of code.
eval is useful when your php code is stored in database.
read here http://www.php.net/manual/en/function.eval.php for details.
I'm going to go out on a limb here... it would probably make your
application faster if you used a file based cache for content to be
eval'd and then included the cached file instead. Then whatever
accelerator is in play can do it's thing on the code.
But the poster didn't ask about content in general, he asked about the
difference between include and eval'ing content acquired from a file.
Application and Templating Framework for PHP
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php