0

I try to cache a php file. This php file is just an HTML file with some include and variable in it.

I want to execute this php file one time and then put it in an .html file.

I tried :

ob_start();
include('source.php');
$file_content = ob_get_contents();
file_put_contents('cache.html', $file_content);
ob_end_clean();

It dosn't work because there are some include functions in source.php, the file cache.html is not created and the output of ob_start is visible.

If I remove the include functions in source.php it works well.

Any ideas ?

Thanks

pol
  • 46
  • 1
  • 8
  • 1
    Do any of the files being included use `ob_XXX` functions? – Barmar Jun 07 '13 at 16:43
  • It's not writing at all? Check to ensure the directory is writable. If the file is there, view it to see if there's an error. – Rob W Jun 07 '13 at 16:43
  • @RobW He says it works if he removes the `include` calls, so he presumably has permission. – Barmar Jun 07 '13 at 16:44
  • Check for errors in the PHP log. Maybe one of the include files is causing an error, so the rest of the script isn't running. – Barmar Jun 07 '13 at 16:45
  • If there are includes in the templates it's probably breaking on not being able to resolve the path to the includes in the includes. Crank error reporting up to 11 and see what you get. – Orangepill Jun 07 '13 at 16:51
  • Thanks for your answers, my mistake, as Orangepill said it was an error in an included file.. – pol Jun 08 '13 at 00:43

0 Answers0