For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > July 2004 > Put in file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Put in file
Juan Pablo Herrera

2004-07-08, 4:04 pm

Hi!
I need put the content of $smarty->display(template.tpl), in a file .txt.
The function that using in php is fwrite. Can I using this function?

Thank You.
Juan
Pete M

2004-07-09, 4:02 pm

Juan Pablo Herrera wrote:

> Hi!
> I need put the content of $smarty->display(template.tpl), in a file .txt.
> The function that using in php is fwrite. Can I using this function?
>
> Thank You.
> Juan

<?php
$filename = 'test.txt';

$content = $smarty->fetch('template.tpl');

if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
if (!fwrite($handle, $content)) {
print "Cannot write to file ($filename)";
exit;
}
fclose($handle);
}
?>

I also use the $smarty-.fetch('email.txt') to send emails. Works a treat !!
Pete
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com