i have the following function.
Code: Select all
<?php
function adapt($tpl,$outfile, $mode='w'){
ob_start();
require $tpl;
$tplContents = ob_get_contents();
ob_end_clean();
$fp = fopen($outfile, $mode);
fputs($fp, $tplContents);
fclose($fp);
}
?>
I use it (in command line mode) to read a php script (in the file given as $tpl), parse it and write the result to a file named $outfile. i can call it like given below.
Code: Select all
<?php
adapt('template1.php','testout.txt');
?>
contents of my template1.php file includes another call to the same adapt function, like given below.
Code: Select all
<?php
adapt('template2.php','testout.txt');
?>
since two calls involve different $tpl files, it does not end up in an infinite loop. I want both function calls to append to the same file. But they do not. Only the first call add to the file it seems. If the output files are different, they work as expected (i.e. two files will be created with expected output).
Can anybody suggest what i'm doing wrong

? If i'm not made my problem clear pls indicate
