Jump to content

Minklet

Members
  • Posts

    88
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Minklet's Achievements

Member

Member (2/5)

0

Reputation

  1. I'm trying to tidy up my code by getting to grips with OOP. I know that this isnt really OOP, but I want to put a cache system into a function. The bit in comments is basically the bit that I want to put into a function. As you can see its fairly rudimentary but basically I dont know how to get what 'include' produces into the output buffer because, of course, its not actually outputting anything. I thought something like fopen() but its all PHP scripts in the include so taht wont work Anyway, this is what I have: $cachefile = 'cache/cache_blogphotofeed.html'; $include = 'feeds/blogphoto_feed.php'; $table = 'our_photos'; if (file_exists($cachefile)) { if (is_outdated($cachefile, $table, $dbc)) { // This bit ob_start(); include($include); $fp = fopen($cachefile, 'w'); fwrite($fp, ob_get_contents()); fclose($fp); // close the file ob_end_flush();[/b] // To this bit } else { include($cachefile); } } else { ob_start(); include($include); $fp = fopen($cachefile, 'w'); fwrite($fp, ob_get_contents()); fclose($fp); // close the file ob_end_flush(); } The function is_outdated simply checks if the database table has been modified more recently than the cache file Any suggestions at all?
×
×
  • 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.