summaryrefslogtreecommitdiffstats
path: root/write-to-file-using-ob.php
blob: 89a35532c740e7811b26b1c9e5d0d13f0d9c87d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

ob_start();

echo '<?php'; // this will go into our file
// stop php from interpreting, now write content of file freely!
?> 
echo 'hello, world!';

<?php
echo '?>'; // this will go into our file

$content = ob_get_flush();
file_put_contents('foo.txt', $content);

?>