Can anyone tell me why this code snippet doesn't work? I have it at the end of my document after everything has been processed. I can get it to work using fopen, but thought I'd try to refine it: <?php $fileCache = "/home/site/www/cache/acache.html"; ob_flush();
Which version of PHP? file_put_contents() was made available in PHP 5 I believe it was. If you have an earlier version of PHP you will have to write your own function or keep using fopen and fwrite, ... which is likely what your own file_put_contents() function will do.
You're flushing the buffer before writing the file so you're writing an empty buffer.
Quote from the manual on ob_flush():
This function will send the contents of the output buffer (if any). If you want to further process the buffer's contents you have to call ob_get_contents() before ob_flush() as the buffer contents are discarded after ob_flush() is called.