note 39996 deleted from function.ob-get-contents by aidan
| From: | aidan@php.net | Date: | Sun, 14 Nov 2004 17:09:57 +0000 |
| Subject: | note 39996 deleted from function.ob-get-contents by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80517@lists.php.net to get a copy of this message | ||
Note Submitter: mail at nospamiaindooley dot com
----
want to use templates to write files from a php script? here's one way:
<?php
/*set whatever values will be printed in the template*/
$var1 = "some value";
$var2 = "some other value";
/*start the output buffering*/
ob_start();
/*include the tempate file*/
require("template.inc");
/*get the contenst of the output buffer*/
$data = ob_get_contents();
/*write the contents to a file*/
$fp = fopen("somefile.txt","w");
fwrite($fp,$data);
fclose($fp);
/*clear the output buffer*/
ob_clean();
/*display some other page - like "you have successfully written a file" or something*/
require("return_url.php");
?>
too easy!!