On Mon, 09 Aug 2004 20:04:50 -0400, Gambler ZG <[EMAIL PROTECTED]> wrote:
>  > Much better to use a *function* which is parsed once
>  > then include()ing or eval()ing the same code over and over to
> (possibly) be
>  > re-parsed.
> 
> //I read file once:
> $handle = fopen($fileName, "r");
> $script = 'function use_cached_code(){
> ?>';
> $script. = fread($handle, filesize($fileName));
> $script. = '<?php
> }';
> 
> //parse it once:
> eval($script);
> 
> //and use the code as much as I want:
> use_cached_code();
> 
>  > It just makes more sense code structure-wise as well.
> 
> Not in my case, believe me. Otherwise I would not ask about caching.

*Maybe* if you *must* use this around *someone else's* code that you
are *not allowed* to change would you use this, but I simply don't
understand why you would do such a thing. You could add the function
name and the bottom part to the file and just include() it. End of
problem.

If this is a "template" that someone else is editing, I would suggest
using a templating system already out there to do the caching and such
for you. This is really a nasty hack. If you want to use PHP-style
syntax, Savant is your friend.

> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to