Studiati questo codice:
Codice PHP:
<?php
$cache_file = dirname(__FILE__) . '/cached.htm';
$cache_time = 60 * 60; // in seconds
if (is_readable($cache_file) && (filemtime($cache_file) > time() - $cache_time)) {
include($cache_file);
exit();
}
function cache($content) {
global $cache_file;
file_put_contents($cache_file, $content);
return $content;
}
ob_start('cache');
?>
Hello World! <?php echo(date("H:i:s")); ?>