The code below almost works, but it\'s not what I really meant:
ob_start(); echo \'xxx\'; $contents = ob_get_contents(); ob_end_clean(); file_put_contents($f
No, output buffering is as good as it gets. Though it's slightly nicer to just do
ob_start(); echo 'xxx'; $contents = ob_get_flush(); file_put_contents($file,$contents);