Echo Output To a Flat File in PHP

By | January 4, 2013

So here is a program that might help you echo the output from a php file to a flat file. Now the flat file can be anything, it can be an html file, text file or whatever.! Just use the following code, edit places where required and it should work fine.!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

$num = "123";
$name = "vamsi";

ob_start();

echo "<html>";
echo "id value is $num \n";
echo "Mynamee is $name \n";
echo "</html>";

$s = ob_get_contents();

ob_end_clean();

$f = fopen("vamsi.html", "w");
fwrite($f, "$s");
fclose($f);

?>

If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!

Leave a Reply

Your email address will not be published. Required fields are marked *