Re: How PHP handles multiple inclusions of the same file?
| From: | Curt Zirzow | Date: | Mon, 09 Aug 2004 14:51:07 +0000 |
| Subject: | Re: How PHP handles multiple inclusions of the same file? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193197@lists.php.net to get a copy of this message | ||
* Thus wrote Gambler ZG:
> >what do you mean by that?
>
> Nothing. The statement was based on the erroneous assumption that
> anonimous functions allow to go into HTML mode with '?>'. But this will
> not stop me, for there is eval()! The general idea is simple - to use
> some file's code multiple times without re-reading the file and
> re-parsing its content. So...
>
> $file = "some/script.php";
> $handle = fopen($file, "r");
> $script = fread($handle, filesize($file));
> $script = 'function use_cached_code(){
> ?>'.$script.'<?php
> }';
> eval($script);
Here is a better way to create a dynamaic function:
$use_cache_code = create_function('', $script);
$use_cache_code();
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!