note 39996 added to function.ob-get-contents
| From: | mail at nospamiaindooley dot com | Date: | Wed, 18 Feb 2004 05:57:03 +0000 |
| Subject: | note 39996 added to function.ob-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65334@lists.php.net to get a copy of this message | ||
want to use templates to write files from a php script? here's one way:
/*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!!
----
Manual Page -- http://www.php.net/manual/en/function.ob-get-contents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39996
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39996&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39996&report=yes
Search -- http://master.php.net/manage/user-notes.php