Re: include()ing into a variable
| From: | Curt Zirzow | Date: | Thu, 14 Oct 2004 19:25:59 +0000 |
| Subject: | Re: include()ing into a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199517@lists.php.net to get a copy of this message | ||
* Thus wrote Mag:
> Hi,
> I have never done this before (but in my first test it
> seems to work), I am include()ing a file into a
> variable like this:
>
> $a=include("th-file.php");
>
> Will this give me any extra problems later on? or is
> this resource intensive?
>
> The reason I am doing this is because I want to put
> whole pages into a variable then write the contents of
> the variable to a static html file...
Writing everything to a variable doesn't make much sense to me, I'd
write a little wrapper for Output Buffering to use:
class SaveToFile {
function open($file) {
//open file...
}
function write($buf) {
//write to file...
}
function close() {
//close file
}
}
$obSaveFile = new SaveToFile();
$obSaveFile->open('/path/to/file.html');
ob_start(array(&$obSaveFile, 'save'), 1024);
/* do your stuff here */
ob_end_flush();
$obSaveFile->close();
Curt
--
Quoth the Raven, "Nevermore."