Jump to content

object

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Everything posted by object

  1. You can use output buffering to capture your php scripts output before it is sent to the browser, then store the output in a html file. Then change the links on your website to point to the html files instead of the php files. With some more coding, you can create one php script that will create cache files of your entire web directory. Of course this is all dependent on whether or not you host allows output buffering, and at what byte size. Use the following code as a guide. <? ob_start(); //starts output buffering include( $path_to_php_script ); // when a php script is included, it is first executed, so the include function returns the html output of the php file $html = ob_get_contents(); // gets the contents of the output buffer, which is your html, and stores them in $html ob_end_clean(); // ends output buffering, and does not output the buffer to browser $new_cache = fopen( $path_to_html_file, "w" ); // will create a new file, or open and overwrite it if it already exists flock( $new_cache, LOCK_EX ); // locks file to prevent errors when writing fwrite( $new_cache, $html ); // writes html from $html to file flock( $new_cache, LOCK_UN ); // unlocks file fclose( $new_cache ); // closes file ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.